Index: logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java =================================================================== --- logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java (revision 1601) +++ logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java (working copy) @@ -212,7 +212,10 @@ } public Enumeration getRequestHeaderNames() { - return httpRequest.getHeaderNames(); + if(httpRequest==null) { + return null; + } + return httpRequest.getHeaderNames(); } public Map getRequestHeaderMap() { @@ -223,7 +226,10 @@ } public void buildRequestHeaderMap() { - requestHeaderMap = new HashMap(); + requestHeaderMap = new HashMap(); + if(httpRequest==null) { + return; + } Enumeration e = httpRequest.getHeaderNames(); if (e == null) { return; @@ -235,8 +241,11 @@ } public void buildRequestParameterMap() { - requestParameterMap = new HashMap(); - Enumeration e = httpRequest.getParameterNames(); + requestParameterMap = new HashMap(); + if(httpRequest==null) { + return; + } + Enumeration e = httpRequest.getParameterNames(); if (e == null) { return; } @@ -247,11 +256,17 @@ } public String getResponseHeader(String key) { + if(serverAdapter==null) { + return null; + } return serverAdapter.getResponseHeader(key); } public List getResponseHeaderNameList() { - return serverAdapter.getResponseHeaderNameList(); + if(serverAdapter==null) { + return null; + } + return serverAdapter.getResponseHeaderNameList(); } /** @@ -305,7 +320,7 @@ public long getContentLength() { if (contentLength == SENTINEL) { - if (httpResponse != null) { + if (serverAdapter != null) { contentLength = serverAdapter.getContentLength(); return contentLength; } @@ -315,7 +330,7 @@ public int getStatusCode() { if (statusCode == SENTINEL) { - if (httpResponse != null) { + if (serverAdapter != null) { statusCode = serverAdapter.getStatusCode(); } } @@ -327,8 +342,10 @@ if (requestContent != null) { return requestContent; } - - if (Util.isFormUrlEncoded(httpRequest)) { + if(httpRequest == null) { + return null; + } + if (Util.isFormUrlEncoded(httpRequest)) { StringBuffer buf = new StringBuffer(); Enumeration pramEnumeration = httpRequest.getParameterNames(); @@ -380,12 +397,17 @@ return responseContent; } - if (Util.isImageResponse(httpResponse)) { + if(httpResponse == null || httpRequest == null) { + return null; + } + + if (Util.isImageResponse(httpResponse)) { responseContent = "[IMAGE CONTENTS SUPPRESSED]"; } else { // retreive the byte array previously placed by TeeFilter - byte[] outputBuffer = (byte[]) httpRequest + // TODO: please check if httpRequest below is correct. + byte[] outputBuffer = (byte[]) httpRequest .getAttribute(Constants.LB_OUTPUT_BUFFER); if (outputBuffer != null) {