From c5fd916b1d281ffaaf6faafd18762c30a8f8bfa3 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 06 May 2013 07:49:18 +0000
Subject: [PATCH] OPENDJ-879 (CR-1642) Add HTTP access log

---
 opends/src/server/org/opends/server/loggers/HTTPRequestInfo.java |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/opends/src/server/org/opends/server/loggers/HTTPRequestInfo.java b/opends/src/server/org/opends/server/loggers/HTTPRequestInfo.java
index 8accb23..e9867bb 100644
--- a/opends/src/server/org/opends/server/loggers/HTTPRequestInfo.java
+++ b/opends/src/server/org/opends/server/loggers/HTTPRequestInfo.java
@@ -26,6 +26,8 @@
  */
 package org.opends.server.loggers;
 
+import java.util.concurrent.atomic.AtomicInteger;
+
 import javax.servlet.http.HttpServletRequest;
 
 /**
@@ -49,8 +51,11 @@
 
   /** The username that was used to authenticate. */
   private String authUser;
-  /** The HTTP status code returned to the client. */
-  private volatile Integer statusCode;
+  /**
+   * The HTTP status code returned to the client. Using 0 to say no status code
+   * was set since it is not .
+   */
+  private AtomicInteger statusCode = new AtomicInteger(0);
 
   /**
    * Constructor for this class.
@@ -156,7 +161,8 @@
    */
   public int getStatusCode()
   {
-    return statusCode != null ? statusCode : 200;
+    int sc = statusCode.get();
+    return sc != 0 ? sc : 200;
   }
 
   /**
@@ -167,9 +173,8 @@
    */
   public void log(int statusCode)
   {
-    if (this.statusCode == null)
+    if (this.statusCode.compareAndSet(0, statusCode))
     { // this request was not logged before
-      this.statusCode = statusCode;
       HTTPAccessLogger.logRequestInfo(this);
     }
   }

--
Gitblit v1.10.0