Index: src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java =================================================================== --- src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java (revision 1612) +++ src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java (working copy) @@ -1,14 +1,13 @@ package ch.qos.logback.access.jetty; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - +import ch.qos.logback.access.spi.ServerAdapter; import org.mortbay.jetty.HttpFields; import org.mortbay.jetty.Request; import org.mortbay.jetty.Response; -import ch.qos.logback.access.spi.ServerAdapter; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; /** * A jetty specific implementation of the {@link ServerAdapter} interface. @@ -35,7 +34,7 @@ } - public Map builResponseHeaderMap() { + public Map buildResponseHeaderMap() { Map responseHeaderMap = new HashMap(); HttpFields httpFields = response.getHttpFields(); Enumeration e = httpFields.getFieldNames(); Index: src/main/java/ch/qos/logback/access/spi/AccessEvent.java =================================================================== --- src/main/java/ch/qos/logback/access/spi/AccessEvent.java (revision 1612) +++ src/main/java/ch/qos/logback/access/spi/AccessEvent.java (working copy) @@ -1,21 +1,15 @@ package ch.qos.logback.access.spi; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; +import ch.qos.logback.access.Constants; +import ch.qos.logback.access.pattern.AccessConverter; +import ch.qos.logback.access.servlet.Util; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.Serializable; +import java.util.*; -import ch.qos.logback.access.Constants; -import ch.qos.logback.access.pattern.AccessConverter; -import ch.qos.logback.access.servlet.Util; - // Contributors: Joern Huxhorn (see also bug #110) /** @@ -205,10 +199,10 @@ if (requestHeaderMap == null) { if (httpRequest != null) { buildRequestHeaderMap(); - result = (String) requestHeaderMap.get(key); + result = requestHeaderMap.get(key); } } else { - result = (String) requestHeaderMap.get(key); + result = requestHeaderMap.get(key); } if (result != null) { @@ -270,7 +264,6 @@ * Attributes are not serialized * * @param key - * @return */ public String getAttribute(String key) { if (httpRequest != null) { @@ -306,9 +299,9 @@ return AccessEvent.NA; } - for (int i = 0; cookieArray != null && i < cookieArray.length; i++) { - if (key.equals(cookieArray[i].getName())) { - return cookieArray[i].getValue(); + for (Cookie cookie : cookieArray) { + if (key.equals(cookie.getName())) { + return cookie.getValue(); } } } @@ -340,47 +333,49 @@ return requestContent; } - if (Util.isFormUrlEncoded(httpRequest)) { - StringBuffer buf = new StringBuffer(); + if(httpRequest != null) { + if (Util.isFormUrlEncoded(httpRequest)) { + StringBuffer buf = new StringBuffer(); - Enumeration pramEnumeration = httpRequest.getParameterNames(); + Enumeration pramEnumeration = httpRequest.getParameterNames(); - // example: id=1234&user=cgu - // number=1233&x=1 - int count = 0; - try { - while (pramEnumeration.hasMoreElements()) { + // example: id=1234&user=cgu + // number=1233&x=1 + int count = 0; + try { + while (pramEnumeration.hasMoreElements()) { - String key = (String) pramEnumeration.nextElement(); - if (count++ != 0) { - buf.append("&"); + String key = (String) pramEnumeration.nextElement(); + if (count++ != 0) { + buf.append("&"); + } + buf.append(key); + buf.append("="); + String val = httpRequest.getParameter(key); + if (val != null) { + buf.append(val); + } else { + buf.append(""); + } } - buf.append(key); - buf.append("="); - String val = httpRequest.getParameter(key); - if (val != null) { - buf.append(val); - } else { - buf.append(""); - } + } catch (Exception e) { + // FIXME Why is try/catch required? + e.printStackTrace(); } - } catch (Exception e) { - // FIXME Why is try/catch required? - e.printStackTrace(); - } - requestContent = buf.toString(); - } else { + requestContent = buf.toString(); + } else { - // retreive the byte array placed by TeeFilter - byte[] inputBuffer = (byte[]) httpRequest - .getAttribute(Constants.LB_INPUT_BUFFER); + // retreive the byte array placed by TeeFilter + byte[] inputBuffer = (byte[]) httpRequest + .getAttribute(Constants.LB_INPUT_BUFFER); - if (inputBuffer != null) { - requestContent = new String(inputBuffer); - } + if (inputBuffer != null) { + requestContent = new String(inputBuffer); + } - if (requestContent == null || requestContent.length() == 0) { - requestContent = EMPTY; + if (requestContent == null || requestContent.length() == 0) { + requestContent = EMPTY; + } } } @@ -432,7 +427,11 @@ void buildResponseHeaderMap() { if (responseHeaderMap == null) { - responseHeaderMap = serverAdapter.builResponseHeaderMap(); + if(serverAdapter != null) { + responseHeaderMap = serverAdapter.buildResponseHeaderMap(); + } else { + responseHeaderMap = new HashMap(); + } } } Index: src/main/java/ch/qos/logback/access/spi/ServerAdapter.java =================================================================== --- src/main/java/ch/qos/logback/access/spi/ServerAdapter.java (revision 1612) +++ src/main/java/ch/qos/logback/access/spi/ServerAdapter.java (working copy) @@ -17,5 +17,5 @@ // List getResponseHeaderNameList(); // Map getResponseHeaderMap(); - Map builResponseHeaderMap(); + Map buildResponseHeaderMap(); } Index: src/main/java/ch/qos/logback/access/tomcat/TomcatServerAdapter.java =================================================================== --- src/main/java/ch/qos/logback/access/tomcat/TomcatServerAdapter.java (revision 1612) +++ src/main/java/ch/qos/logback/access/tomcat/TomcatServerAdapter.java (working copy) @@ -1,12 +1,11 @@ package ch.qos.logback.access.tomcat; -import java.util.HashMap; -import java.util.Map; - +import ch.qos.logback.access.spi.ServerAdapter; import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Response; -import ch.qos.logback.access.spi.ServerAdapter; +import java.util.HashMap; +import java.util.Map; /** * A tomcat specific implementation of the {@link ServerAdapter} interface. @@ -32,7 +31,7 @@ } - public Map builResponseHeaderMap() { + public Map buildResponseHeaderMap() { Map responseHeaderMap = new HashMap(); for (String key : response.getHeaderNames()) { String value = response.getHeader(key); Index: src/test/java/ch/qos/logback/access/dummy/DummyServerAdapter.java =================================================================== --- src/test/java/ch/qos/logback/access/dummy/DummyServerAdapter.java (revision 1612) +++ src/test/java/ch/qos/logback/access/dummy/DummyServerAdapter.java (working copy) @@ -22,7 +22,7 @@ return response.getStatus(); } - public Map builResponseHeaderMap() { + public Map buildResponseHeaderMap() { return response.headerMap; }