mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
06.49.2013 c5fd916b1d281ffaaf6faafd18762c30a8f8bfa3
OPENDJ-879 (CR-1642) Add HTTP access log

HTTPRequestInfo.java:
Changed statusCode to use AtomicInteger instead of volatile Integer to better protect against concurrency.
1 files modified
15 ■■■■■ changed files
opends/src/server/org/opends/server/loggers/HTTPRequestInfo.java 15 ●●●●● patch | view | raw | blame | history
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);
    }
  }