From f9f95f24adb8d1e30562dcd379fb77dc966adc11 Mon Sep 17 00:00:00 2001
From: Denis Bazhenov <bazhenov@farpost.com>
Date: Tue, 7 Dec 2010 16:53:51 +1000
Subject: [PATCH 1/3] Add checks agains NPE on httpRequest

---
 .../ch/qos/logback/access/spi/AccessEvent.java     |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java
index 6596aaf..5ddff34 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java
@@ -267,6 +267,9 @@ public class AccessEvent implements Serializable, DeferredProcessingAware {
     // according to RFC 2616 header names are case insensitive
     // latest versions of Tomcat return header names in lower-case
     requestHeaderMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
+		if (httpRequest == null) {
+			return;
+		}
     Enumeration e = httpRequest.getHeaderNames();
     if (e == null) {
       return;
@@ -279,6 +282,9 @@ public class AccessEvent implements Serializable, DeferredProcessingAware {
 
   public void buildRequestParameterMap() {
     requestParameterMap = new HashMap<String, String[]>();
+		if (httpRequest == null) {
+			return;
+		}
     Enumeration e = httpRequest.getParameterNames();
     if (e == null) {
       return;
@@ -424,6 +430,9 @@ public class AccessEvent implements Serializable, DeferredProcessingAware {
       responseContent = "[IMAGE CONTENTS SUPPRESSED]";
     } else {
 
+		if (httpRequest == null) {
+			return null;
+		}
       // retreive the byte array previously placed by TeeFilter
       byte[] outputBuffer = (byte[]) httpRequest
           .getAttribute(AccessConstants.LB_OUTPUT_BUFFER);
-- 
1.7.1


From 5dd20b3db018c530e9058fb70ad2c3e0720a647d Mon Sep 17 00:00:00 2001
From: Denis Bazhenov <bazhenov@farpost.com>
Date: Tue, 7 Dec 2010 16:55:46 +1000
Subject: [PATCH 2/3] syntax conventions

---
 .../ch/qos/logback/access/spi/AccessEvent.java     |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java
index 5ddff34..1ffeb71 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java
@@ -267,9 +267,9 @@ public class AccessEvent implements Serializable, DeferredProcessingAware {
     // according to RFC 2616 header names are case insensitive
     // latest versions of Tomcat return header names in lower-case
     requestHeaderMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
-		if (httpRequest == null) {
-			return;
-		}
+    if (httpRequest == null) {
+      return;
+    }
     Enumeration e = httpRequest.getHeaderNames();
     if (e == null) {
       return;
@@ -282,9 +282,9 @@ public class AccessEvent implements Serializable, DeferredProcessingAware {
 
   public void buildRequestParameterMap() {
     requestParameterMap = new HashMap<String, String[]>();
-		if (httpRequest == null) {
-			return;
-		}
+    if (httpRequest == null) {
+      return;
+    }
     Enumeration e = httpRequest.getParameterNames();
     if (e == null) {
       return;
@@ -430,9 +430,9 @@ public class AccessEvent implements Serializable, DeferredProcessingAware {
       responseContent = "[IMAGE CONTENTS SUPPRESSED]";
     } else {
 
-		if (httpRequest == null) {
-			return null;
-		}
+    if (httpRequest == null) {
+      return null;
+    }
       // retreive the byte array previously placed by TeeFilter
       byte[] outputBuffer = (byte[]) httpRequest
           .getAttribute(AccessConstants.LB_OUTPUT_BUFFER);
-- 
1.7.1


From 55de45b8c082c268f1d698b2affcdd52cf8387fa Mon Sep 17 00:00:00 2001
From: Denis Bazhenov <bazhenov@farpost.com>
Date: Wed, 8 Dec 2010 10:58:01 +1000
Subject: [PATCH 3/3] fixed possible parameters erasing in buildRequestParameterMap()

---
 .../ch/qos/logback/access/spi/AccessEvent.java     |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java
index 1ffeb71..d466354 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java
@@ -266,10 +266,10 @@ public class AccessEvent implements Serializable, DeferredProcessingAware {
   public void buildRequestHeaderMap() {
     // according to RFC 2616 header names are case insensitive
     // latest versions of Tomcat return header names in lower-case
-    requestHeaderMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
     if (httpRequest == null) {
       return;
     }
+    requestHeaderMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
     Enumeration e = httpRequest.getHeaderNames();
     if (e == null) {
       return;
@@ -281,10 +281,10 @@ public class AccessEvent implements Serializable, DeferredProcessingAware {
   }
 
   public void buildRequestParameterMap() {
-    requestParameterMap = new HashMap<String, String[]>();
     if (httpRequest == null) {
       return;
     }
+    requestParameterMap = new HashMap<String, String[]>();
     Enumeration e = httpRequest.getParameterNames();
     if (e == null) {
       return;
-- 
1.7.1

