tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1390718 [1/2] - in /tomcat/sandbox/trunk-resources: ./ java/org/apache/catalina/connector/ java/org/apache/catalina/core/ java/org/apache/catalina/valves/ java/org/apache/coyote/ java/org/apache/coyote/ajp/ java/org/apache/coyote/http11/ j...
Date Wed, 26 Sep 2012 20:35:26 GMT
Author: markt
Date: Wed Sep 26 20:35:24 2012
New Revision: 1390718

URL: http://svn.apache.org/viewvc?rev=1390718&view=rev
Log:
Sync with trunk

Added:
    tomcat/sandbox/trunk-resources/java/org/apache/tomcat/util/collections/SynchronizedQueue.java
      - copied unchanged from r1390717, tomcat/trunk/java/org/apache/tomcat/util/collections/SynchronizedQueue.java
    tomcat/sandbox/trunk-resources/java/org/apache/tomcat/util/collections/SynchronizedStack.java
      - copied unchanged from r1390717, tomcat/trunk/java/org/apache/tomcat/util/collections/SynchronizedStack.java
    tomcat/sandbox/trunk-resources/test/org/apache/tomcat/util/collections/
      - copied from r1390717, tomcat/trunk/test/org/apache/tomcat/util/collections/
Modified:
    tomcat/sandbox/trunk-resources/   (props changed)
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/Connector.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/Request.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/StandardHostValve.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/AccessLogValve.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/Constants.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/AbstractProtocol.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/ProtocolHandler.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpAprProtocol.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpNioProtocol.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpProtocol.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/AbstractHttp11Processor.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11AprProcessor.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11AprProtocol.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11NioProcessor.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11NioProtocol.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11Processor.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11Protocol.java
    tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
    tomcat/sandbox/trunk-resources/java/org/apache/tomcat/util/buf/B2CConverter.java
    tomcat/sandbox/trunk-resources/java/org/apache/tomcat/util/net/NioBlockingSelector.java
    tomcat/sandbox/trunk-resources/java/org/apache/tomcat/util/net/NioEndpoint.java
    tomcat/sandbox/trunk-resources/java/org/apache/tomcat/util/net/SocketWrapper.java
    tomcat/sandbox/trunk-resources/webapps/docs/config/valve.xml

Propchange: tomcat/sandbox/trunk-resources/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1388713-1390717

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/Connector.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/Connector.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/Connector.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/Connector.java Wed Sep 26 20:35:24 2012
@@ -20,6 +20,7 @@ import java.net.InetAddress;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Locale;
 
 import javax.management.ObjectName;
 
@@ -225,6 +226,7 @@ public class Connector extends Lifecycle
       * URI encoding.
       */
      protected String URIEncoding = null;
+     protected String URIEncodingLower = null;
 
 
      /**
@@ -740,12 +742,19 @@ public class Connector extends Lifecycle
     }
 
      /**
-      * Return the character encoding to be used for the URI.
+      * Return the character encoding to be used for the URI using the original
+      * case.
       */
      public String getURIEncoding() {
+         return this.URIEncoding;
+     }
 
-         return (this.URIEncoding);
 
+     /**
+      * Return the character encoding to be used for the URI using lower case.
+      */
+     public String getURIEncodingLower() {
+         return this.URIEncodingLower;
      }
 
 
@@ -755,10 +764,9 @@ public class Connector extends Lifecycle
       * @param URIEncoding The new URI character encoding.
       */
      public void setURIEncoding(String URIEncoding) {
-
          this.URIEncoding = URIEncoding;
+         this.URIEncodingLower = URIEncoding.toLowerCase(Locale.US);
          setProperty("uRIEncoding", URIEncoding);
-
      }
 
 

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/CoyoteAdapter.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/CoyoteAdapter.java Wed Sep 26 20:35:24 2012
@@ -78,6 +78,16 @@ public class CoyoteAdapter implements Ad
         Boolean.valueOf(System.getProperty("org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH", "false")).booleanValue();
 
 
+    private static final ThreadLocal<String> THREAD_NAME =
+            new ThreadLocal<String>() {
+
+                @Override
+                protected String initialValue() {
+                    return Thread.currentThread().getName();
+                }
+
+    };
+
     // ----------------------------------------------------------- Constructors
 
 
@@ -427,7 +437,7 @@ public class CoyoteAdapter implements Ad
 
             // Parse and set Catalina and configuration specific
             // request parameters
-            req.getRequestProcessor().setWorkerThreadName(Thread.currentThread().getName());
+            req.getRequestProcessor().setWorkerThreadName(THREAD_NAME.get());
             boolean postParseSuccess = postParseRequest(req, request, res, response);
             if (postParseSuccess) {
                 //check valves if we support async
@@ -837,13 +847,13 @@ public class CoyoteAdapter implements Ad
 
         // What encoding to use? Some platforms, eg z/os, use a default
         // encoding that doesn't give the expected result so be explicit
-        String enc = connector.getURIEncoding();
+        String enc = connector.getURIEncodingLower();
         if (enc == null) {
-            enc = "ISO-8859-1";
+            enc = "iso-8859-1";
         }
         Charset charset = null;
         try {
-            charset = B2CConverter.getCharset(enc);
+            charset = B2CConverter.getCharsetLower(enc);
         } catch (UnsupportedEncodingException e1) {
             log.warn(sm.getString("coyoteAdapter.parsePathParam",
                     enc));

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/Request.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/Request.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/connector/Request.java Wed Sep 26 20:35:24 2012
@@ -3225,5 +3225,44 @@ public class Request
                         // NO-OP
                     }
                 });
+        specialAttributes.put(Globals.COMET_SUPPORTED_ATTR,
+                new SpecialAttributeAdapter() {
+                    @Override
+                    public Object get(Request request, String name) {
+                        return Boolean.valueOf(
+                                request.getConnector().getProtocolHandler(
+                                        ).isCometSupported());
+                    }
+                    @Override
+                    public void set(Request request, String name, Object value) {
+                        // NO-OP
+                    }
+                });
+        specialAttributes.put(Globals.COMET_TIMEOUT_SUPPORTED_ATTR,
+                new SpecialAttributeAdapter() {
+                    @Override
+                    public Object get(Request request, String name) {
+                        return Boolean.valueOf(
+                                request.getConnector().getProtocolHandler(
+                                        ).isCometTimeoutSupported());
+                    }
+                    @Override
+                    public void set(Request request, String name, Object value) {
+                        // NO-OP
+                    }
+                });
+        specialAttributes.put(Globals.SENDFILE_SUPPORTED_ATTR,
+                new SpecialAttributeAdapter() {
+                    @Override
+                    public Object get(Request request, String name) {
+                        return Boolean.valueOf(
+                                request.getConnector().getProtocolHandler(
+                                        ).isSendfileSupported());
+                    }
+                    @Override
+                    public void set(Request request, String name, Object value) {
+                        // NO-OP
+                    }
+                });
     }
 }

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/StandardHostValve.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/StandardHostValve.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/StandardHostValve.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/StandardHostValve.java Wed Sep 26 20:35:24 2012
@@ -60,6 +60,12 @@ final class StandardHostValve extends Va
 
     private static final Log log = LogFactory.getLog(StandardHostValve.class);
 
+    // Saves a call to getClassLoader() on very request. Under high load these
+    // calls took just long enough to appear as a hot spot (although a very
+    // minor one) in a profiler.
+    private static final ClassLoader MY_CLASSLOADER =
+            StandardHostValve.class.getClassLoader();
+
     protected static final boolean STRICT_SERVLET_COMPLIANCE;
 
     protected static final boolean ACCESS_SESSION;
@@ -184,12 +190,10 @@ final class StandardHostValve extends Va
 
         // Restore the context classloader
         if (Globals.IS_SECURITY_ENABLED) {
-            PrivilegedAction<Void> pa = new PrivilegedSetTccl(
-                    StandardHostValve.class.getClassLoader());
+            PrivilegedAction<Void> pa = new PrivilegedSetTccl(MY_CLASSLOADER);
             AccessController.doPrivileged(pa);
         } else {
-            Thread.currentThread().setContextClassLoader
-                    (StandardHostValve.class.getClassLoader());
+            Thread.currentThread().setContextClassLoader(MY_CLASSLOADER);
         }
     }
 

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/AccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/AccessLogValve.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/AccessLogValve.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/AccessLogValve.java Wed Sep 26 20:35:24 2012
@@ -25,6 +25,7 @@ import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.net.InetAddress;
+import java.nio.CharBuffer;
 import java.nio.charset.Charset;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -38,6 +39,7 @@ import java.util.TimeZone;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
 import org.apache.catalina.AccessLog;
@@ -51,6 +53,7 @@ import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.buf.B2CConverter;
+import org.apache.tomcat.util.collections.SynchronizedStack;
 
 
 /**
@@ -505,12 +508,6 @@ public class AccessLogValve extends Valv
     }
 
     /**
-     * Resolve hosts.
-     */
-    private boolean resolveHosts = false;
-
-
-    /**
      * Instant when the log daily rotation was last checked.
      */
     private volatile long rotationLastChecked = 0L;
@@ -570,13 +567,29 @@ public class AccessLogValve extends Valv
      */
     protected boolean requestAttributesEnabled = false;
 
-    // ------------------------------------------------------------- Properties
+    /**
+     * Buffer pool used for log message generation. Pool used to reduce garbage
+     * generation.
+     */
+    private SynchronizedStack<CharBuffer> charBuffers =
+            new SynchronizedStack<>();
 
     /**
-     * @return Returns the enabled.
+     * Log message buffers are usually recycled and re-used. To prevent
+     * excessive memory usage, if a buffer grows beyond this size it will be
+     * discarded. The default is 256 characters. This should be set to larger
+     * than the typical access log message size.
      */
-    public boolean getEnabled() {
-        return enabled;
+    private int maxLogMessageBufferSize = 256;
+
+    // ------------------------------------------------------------- Properties
+
+    public int getMaxLogMessageBufferSize() {
+        return maxLogMessageBufferSize;
+    }
+
+    public void setMaxLogMessageBufferSize(int maxLogMessageBufferSize) {
+        this.maxLogMessageBufferSize = maxLogMessageBufferSize;
     }
 
     /**
@@ -596,6 +609,13 @@ public class AccessLogValve extends Valv
     }
 
     /**
+     * @return Returns the enabled.
+     */
+    public boolean getEnabled() {
+        return enabled;
+    }
+
+    /**
      * @param enabled
      *            The enabled to set.
      */
@@ -743,24 +763,6 @@ public class AccessLogValve extends Valv
 
 
     /**
-     * Set the resolve hosts flag.
-     *
-     * @param resolveHosts The new resolve hosts value
-     */
-    public void setResolveHosts(boolean resolveHosts) {
-        this.resolveHosts = resolveHosts;
-    }
-
-
-    /**
-     * Get the value of the resolve hosts flag.
-     */
-    public boolean isResolveHosts() {
-        return resolveHosts;
-    }
-
-
-    /**
      * Return whether the attribute name to look for when
      * performing conditional logging. If null, every
      * request is logged.
@@ -933,13 +935,22 @@ public class AccessLogValve extends Valv
         long start = request.getCoyoteRequest().getStartTime();
         Date date = getDate(start + time);
 
-        StringBuilder result = new StringBuilder(128);
+        CharBuffer result = charBuffers.pop();
+        if (result == null) {
+            result = CharBuffer.allocate(128);
+        }
 
         for (int i = 0; i < logElements.length; i++) {
             logElements[i].addElement(result, date, request, response, time);
         }
 
-        log(result.toString());
+        result.flip();
+        log(result);
+
+        if (result.length() <= maxLogMessageBufferSize) {
+            result.clear();
+            charBuffers.push(result);
+        }
     }
 
 
@@ -1000,7 +1011,7 @@ public class AccessLogValve extends Valv
      *
      * @param message Message to be logged
      */
-    public void log(String message) {
+    public void log(CharBuffer message) {
         if (rotatable) {
             // Only do a logfile switch check once a second, max.
             long systime = System.currentTimeMillis();
@@ -1047,7 +1058,9 @@ public class AccessLogValve extends Valv
         // Log this message
         synchronized(this) {
             if (writer != null) {
-                writer.println(message);
+                writer.write(message.array(), message.arrayOffset(),
+                        message.arrayOffset() + message.limit());
+                writer.println("");
                 if (!buffered) {
                     writer.flush();
                 }
@@ -1229,7 +1242,7 @@ public class AccessLogValve extends Valv
      * AccessLogElement writes the partial message into the buffer.
      */
     protected interface AccessLogElement {
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time);
 
     }
@@ -1239,7 +1252,7 @@ public class AccessLogValve extends Valv
      */
     protected static class ThreadNameElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             RequestInfo info = request.getCoyoteRequest().getRequestProcessor();
             if(info != null) {
@@ -1269,7 +1282,7 @@ public class AccessLogValve extends Valv
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             buf.append(LOCAL_ADDR_VALUE);
         }
@@ -1280,14 +1293,14 @@ public class AccessLogValve extends Valv
      */
     protected class RemoteAddrElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (requestAttributesEnabled) {
                 Object addr = request.getAttribute(REMOTE_ADDR_ATTRIBUTE);
                 if (addr == null) {
                     buf.append(request.getRemoteAddr());
                 } else {
-                    buf.append(addr);
+                    buf.append(addr.toString());
                 }
             } else {
                 buf.append(request.getRemoteAddr());
@@ -1300,7 +1313,7 @@ public class AccessLogValve extends Valv
      */
     protected class HostElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             String value = null;
             if (requestAttributesEnabled) {
@@ -1324,7 +1337,7 @@ public class AccessLogValve extends Valv
      */
     protected static class LogicalUserNameElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             buf.append('-');
         }
@@ -1335,14 +1348,14 @@ public class AccessLogValve extends Valv
      */
     protected class ProtocolElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (requestAttributesEnabled) {
                 Object proto = request.getAttribute(PROTOCOL_ATTRIBUTE);
                 if (proto == null) {
                     buf.append(request.getProtocol());
                 } else {
-                    buf.append(proto);
+                    buf.append(proto.toString());
                 }
             } else {
                 buf.append(request.getProtocol());
@@ -1355,7 +1368,7 @@ public class AccessLogValve extends Valv
      */
     protected static class UserElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (request != null) {
                 String value = request.getRemoteUser();
@@ -1491,7 +1504,7 @@ public class AccessLogValve extends Valv
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             long timestamp = date.getTime();
             long frac;
@@ -1503,10 +1516,10 @@ public class AccessLogValve extends Valv
                 buf.append(localDateCache.get().getFormat(timestamp));
                 break;
             case SEC:
-                buf.append(timestamp / 1000);
+                buf.append(Long.toString(timestamp / 1000));
                 break;
             case MSEC:
-                buf.append(timestamp);
+                buf.append(Long.toString(timestamp));
                 break;
             case MSEC_FRAC:
                 frac = timestamp % 1000;
@@ -1518,7 +1531,7 @@ public class AccessLogValve extends Valv
                         buf.append('0');
                     }
                 }
-                buf.append(frac);
+                buf.append(Long.toString(frac));
                 break;
             case SDF:
                 String temp = localDateCache.get().getFormat(format, locale, timestamp);
@@ -1548,7 +1561,7 @@ public class AccessLogValve extends Valv
      */
     protected static class RequestElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (request != null) {
                 String method = request.getMethod();
@@ -1577,10 +1590,137 @@ public class AccessLogValve extends Valv
      */
     protected static class HttpStatusCodeElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (response != null) {
-                buf.append(response.getStatus());
+                // This approach is used to reduce GC
+                switch (response.getStatus()) {
+                    case HttpServletResponse.SC_CONTINUE:
+                        buf.put(Constants.SC_CONTINUE_CHAR);
+                        break;
+                    case HttpServletResponse.SC_SWITCHING_PROTOCOLS:
+                        buf.put(Constants.SC_SWITCHING_PROTOCOLS_CHAR);
+                        break;
+                    case HttpServletResponse.SC_OK:
+                        buf.put(Constants.SC_OK_CHAR);
+                        break;
+                    case HttpServletResponse.SC_CREATED:
+                        buf.put(Constants.SC_CREATED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_ACCEPTED:
+                        buf.put(Constants.SC_ACCEPTED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_NON_AUTHORITATIVE_INFORMATION:
+                        buf.put(Constants.SC_NON_AUTHORITATIVE_INFORMATION_CHAR);
+                        break;
+                    case HttpServletResponse.SC_NO_CONTENT:
+                        buf.put(Constants.SC_NO_CONTENT_CHAR);
+                        break;
+                    case HttpServletResponse.SC_RESET_CONTENT:
+                        buf.put(Constants.SC_RESET_CONTENT_CHAR);
+                        break;
+                    case HttpServletResponse.SC_PARTIAL_CONTENT:
+                        buf.put(Constants.SC_PARTIAL_CONTENT_CHAR);
+                        break;
+                    case HttpServletResponse.SC_MULTIPLE_CHOICES:
+                        buf.put(Constants.SC_MULTIPLE_CHOICES_CHAR);
+                        break;
+                    case HttpServletResponse.SC_MOVED_PERMANENTLY:
+                        buf.put(Constants.SC_MOVED_PERMANENTLY_CHAR);
+                        break;
+                    case HttpServletResponse.SC_MOVED_TEMPORARILY:
+                        buf.put(Constants.SC_MOVED_TEMPORARILY_CHAR);
+                        break;
+                    case HttpServletResponse.SC_SEE_OTHER:
+                        buf.put(Constants.SC_SEE_OTHER_CHAR);
+                        break;
+                    case HttpServletResponse.SC_NOT_MODIFIED:
+                        buf.put(Constants.SC_NOT_MODIFIED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_USE_PROXY:
+                        buf.put(Constants.SC_USE_PROXY_CHAR);
+                        break;
+                    case HttpServletResponse.SC_TEMPORARY_REDIRECT:
+                        buf.put(Constants.SC_TEMPORARY_REDIRECT_CHAR);
+                        break;
+                    case HttpServletResponse.SC_BAD_REQUEST:
+                        buf.put(Constants.SC_BAD_REQUEST_CHAR);
+                        break;
+                    case HttpServletResponse.SC_UNAUTHORIZED:
+                        buf.put(Constants.SC_UNAUTHORIZED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_PAYMENT_REQUIRED:
+                        buf.put(Constants.SC_PAYMENT_REQUIRED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_FORBIDDEN:
+                        buf.put(Constants.SC_FORBIDDEN_CHAR);
+                        break;
+                    case HttpServletResponse.SC_NOT_FOUND:
+                        buf.put(Constants.SC_NOT_FOUND_CHAR);
+                        break;
+                    case HttpServletResponse.SC_METHOD_NOT_ALLOWED:
+                        buf.put(Constants.SC_METHOD_NOT_ALLOWED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_NOT_ACCEPTABLE:
+                        buf.put(Constants.SC_NOT_ACCEPTABLE_CHAR);
+                        break;
+                    case HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED:
+                        buf.put(Constants.SC_PROXY_AUTHENTICATION_REQUIRED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_REQUEST_TIMEOUT:
+                        buf.put(Constants.SC_REQUEST_TIMEOUT_CHAR);
+                        break;
+                    case HttpServletResponse.SC_CONFLICT:
+                        buf.put(Constants.SC_CONFLICT_CHAR);
+                        break;
+                    case HttpServletResponse.SC_GONE:
+                        buf.put(Constants.SC_GONE_CHAR);
+                        break;
+                    case HttpServletResponse.SC_LENGTH_REQUIRED:
+                        buf.put(Constants.SC_LENGTH_REQUIRED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_PRECONDITION_FAILED:
+                        buf.put(Constants.SC_PRECONDITION_FAILED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE:
+                        buf.put(Constants.SC_REQUEST_ENTITY_TOO_LARGE_CHAR);
+                        break;
+                    case HttpServletResponse.SC_REQUEST_URI_TOO_LONG:
+                        buf.put(Constants.SC_REQUEST_URI_TOO_LONG_CHAR);
+                        break;
+                    case HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE:
+                        buf.put(Constants.SC_UNSUPPORTED_MEDIA_TYPE_CHAR);
+                        break;
+                    case HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE:
+                        buf.put(Constants.SC_REQUESTED_RANGE_NOT_SATISFIABLE_CHAR);
+                        break;
+                    case HttpServletResponse.SC_EXPECTATION_FAILED:
+                        buf.put(Constants.SC_EXPECTATION_FAILED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_INTERNAL_SERVER_ERROR:
+                        buf.put(Constants.SC_INTERNAL_SERVER_ERROR_CHAR);
+                        break;
+                    case HttpServletResponse.SC_NOT_IMPLEMENTED:
+                        buf.put(Constants.SC_NOT_IMPLEMENTED_CHAR);
+                        break;
+                    case HttpServletResponse.SC_BAD_GATEWAY:
+                        buf.put(Constants.SC_BAD_GATEWAY_CHAR);
+                        break;
+                    case HttpServletResponse.SC_SERVICE_UNAVAILABLE:
+                        buf.put(Constants.SC_SERVICE_UNAVAILABLE_CHAR);
+                        break;
+                    case HttpServletResponse.SC_GATEWAY_TIMEOUT:
+                        buf.put(Constants.SC_GATEWAY_TIMEOUT_CHAR);
+                        break;
+                    case HttpServletResponse.SC_HTTP_VERSION_NOT_SUPPORTED:
+                        buf.put(Constants.SC_HTTP_VERSION_NOT_SUPPORTED_CHAR);
+                        break;
+                    default:
+                        // Don't use this for known codes due to the garbage the
+                        // conversion creates
+                        buf.append(Integer.toString(response.getStatus()));
+                        break;
+                }
             } else {
                 buf.append('-');
             }
@@ -1592,17 +1732,17 @@ public class AccessLogValve extends Valv
      */
     protected class LocalPortElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (requestAttributesEnabled) {
                 Object port = request.getAttribute(SERVER_PORT_ATTRIBUTE);
                 if (port == null) {
-                    buf.append(request.getServerPort());
+                    buf.append(Integer.toString(request.getServerPort()));
                 } else {
-                    buf.append(port);
+                    buf.append(port.toString());
                 }
             } else {
-                buf.append(request.getServerPort());
+                buf.append(Integer.toString(request.getServerPort()));
             }
         }
     }
@@ -1621,7 +1761,7 @@ public class AccessLogValve extends Valv
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             // Don't need to flush since trigger for log message is after the
             // response has been committed
@@ -1643,7 +1783,7 @@ public class AccessLogValve extends Valv
             if (length <= 0 && conversion) {
                 buf.append('-');
             } else {
-                buf.append(length);
+                buf.append(Long.toString(length));
             }
         }
     }
@@ -1653,7 +1793,7 @@ public class AccessLogValve extends Valv
      */
     protected static class MethodElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (request != null) {
                 buf.append(request.getMethod());
@@ -1676,19 +1816,19 @@ public class AccessLogValve extends Valv
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (millis) {
-                buf.append(time);
+                buf.append(Long.toString(time));
             } else {
                 // second
-                buf.append(time / 1000);
+                buf.append(Long.toString(time / 1000));
                 buf.append('.');
                 int remains = (int) (time % 1000);
-                buf.append(remains / 100);
+                buf.append(Long.toString(remains / 100));
                 remains = remains % 100;
-                buf.append(remains / 10);
-                buf.append(remains % 10);
+                buf.append(Long.toString(remains / 10));
+                buf.append(Long.toString(remains % 10));
             }
         }
     }
@@ -1698,7 +1838,7 @@ public class AccessLogValve extends Valv
      */
     protected static class QueryElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             String query = null;
             if (request != null) {
@@ -1716,7 +1856,7 @@ public class AccessLogValve extends Valv
      */
     protected static class SessionIdElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (request != null) {
                 if (request.getSession(false) != null) {
@@ -1736,7 +1876,7 @@ public class AccessLogValve extends Valv
      */
     protected static class RequestURIElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (request != null) {
                 buf.append(request.getRequestURI());
@@ -1751,7 +1891,7 @@ public class AccessLogValve extends Valv
      */
     protected static class LocalServerNameElement implements AccessLogElement {
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             buf.append(request.getServerName());
         }
@@ -1768,7 +1908,7 @@ public class AccessLogValve extends Valv
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             buf.append(str);
         }
@@ -1785,7 +1925,7 @@ public class AccessLogValve extends Valv
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             Enumeration<String> iter = request.getHeaders(header);
             if (iter.hasMoreElements()) {
@@ -1810,7 +1950,7 @@ public class AccessLogValve extends Valv
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             String value = "-";
             Cookie[] c = request.getCookies();
@@ -1837,7 +1977,7 @@ public class AccessLogValve extends Valv
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (null != response) {
                 Iterator<String> iter = response.getHeaders(header).iterator();
@@ -1864,7 +2004,7 @@ public class AccessLogValve extends Valv
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             Object value = null;
             if (request != null) {
@@ -1895,7 +2035,7 @@ public class AccessLogValve extends Valv
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             Object value = null;
             if (null != request) {

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/Constants.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/Constants.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/Constants.java Wed Sep 26 20:35:24 2012
@@ -36,4 +36,44 @@ public final class Constants {
         public static final String COMBINED_PATTERN = "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"";
     }
 
+    public static final char[] SC_CONTINUE_CHAR = new char[] {'1', '0', '0'};
+    public static final char[] SC_SWITCHING_PROTOCOLS_CHAR = new char[] {'1', '0', '1'};
+    public static final char[] SC_OK_CHAR = new char[] {'2', '0', '0'};
+    public static final char[] SC_CREATED_CHAR = new char[] {'2', '0', '1'};
+    public static final char[] SC_ACCEPTED_CHAR = new char[] {'2', '0', '2'};
+    public static final char[] SC_NON_AUTHORITATIVE_INFORMATION_CHAR = new char[] {'2', '0', '3'};
+    public static final char[] SC_NO_CONTENT_CHAR = new char[] {'2', '0', '4'};
+    public static final char[] SC_RESET_CONTENT_CHAR = new char[] {'2', '0', '5'};
+    public static final char[] SC_PARTIAL_CONTENT_CHAR = new char[] {'2', '0', '6'};
+    public static final char[] SC_MULTIPLE_CHOICES_CHAR = new char[] {'3', '0', '0'};
+    public static final char[] SC_MOVED_PERMANENTLY_CHAR = new char[] {'3', '0', '1'};
+    public static final char[] SC_MOVED_TEMPORARILY_CHAR = new char[] {'3', '0', '2'};
+    public static final char[] SC_SEE_OTHER_CHAR = new char[] {'3', '0', '3'};
+    public static final char[] SC_NOT_MODIFIED_CHAR = new char[] {'3', '0', '4'};
+    public static final char[] SC_USE_PROXY_CHAR = new char[] {'3', '0', '5'};
+    public static final char[] SC_TEMPORARY_REDIRECT_CHAR = new char[] {'3', '0', '7'};
+    public static final char[] SC_BAD_REQUEST_CHAR = new char[] {'4', '0', '0'};
+    public static final char[] SC_UNAUTHORIZED_CHAR = new char[] {'4', '0', '1'};
+    public static final char[] SC_PAYMENT_REQUIRED_CHAR = new char[] {'4', '0', '2'};
+    public static final char[] SC_FORBIDDEN_CHAR = new char[] {'4', '0', '3'};
+    public static final char[] SC_NOT_FOUND_CHAR = new char[] {'4', '0', '4'};
+    public static final char[] SC_METHOD_NOT_ALLOWED_CHAR = new char[] {'4', '0', '5'};
+    public static final char[] SC_NOT_ACCEPTABLE_CHAR = new char[] {'4', '0', '6'};
+    public static final char[] SC_PROXY_AUTHENTICATION_REQUIRED_CHAR = new char[] {'4', '0', '7'};
+    public static final char[] SC_REQUEST_TIMEOUT_CHAR = new char[] {'4', '0', '8'};
+    public static final char[] SC_CONFLICT_CHAR = new char[] {'4', '0', '9'};
+    public static final char[] SC_GONE_CHAR = new char[] {'4', '1', '0'};
+    public static final char[] SC_LENGTH_REQUIRED_CHAR = new char[] {'4', '1', '1'};
+    public static final char[] SC_PRECONDITION_FAILED_CHAR = new char[] {'4', '1', '2'};
+    public static final char[] SC_REQUEST_ENTITY_TOO_LARGE_CHAR = new char[] {'4', '1', '3'};
+    public static final char[] SC_REQUEST_URI_TOO_LONG_CHAR = new char[] {'4', '1', '4'};
+    public static final char[] SC_UNSUPPORTED_MEDIA_TYPE_CHAR = new char[] {'4', '1', '5'};
+    public static final char[] SC_REQUESTED_RANGE_NOT_SATISFIABLE_CHAR = new char[] {'4', '1', '6'};
+    public static final char[] SC_EXPECTATION_FAILED_CHAR = new char[] {'4', '1', '7'};
+    public static final char[] SC_INTERNAL_SERVER_ERROR_CHAR = new char[] {'5', '0', '0'};
+    public static final char[] SC_NOT_IMPLEMENTED_CHAR = new char[] {'5', '0', '1'};
+    public static final char[] SC_BAD_GATEWAY_CHAR = new char[] {'5', '0', '2'};
+    public static final char[] SC_SERVICE_UNAVAILABLE_CHAR = new char[] {'5', '0', '3'};
+    public static final char[] SC_GATEWAY_TIMEOUT_CHAR = new char[] {'5', '0', '4'};
+    public static final char[] SC_HTTP_VERSION_NOT_SUPPORTED_CHAR = new char[] {'5', '0', '5'};
 }

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/ExtendedAccessLogValve.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/ExtendedAccessLogValve.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/valves/ExtendedAccessLogValve.java Wed Sep 26 20:35:24 2012
@@ -22,6 +22,7 @@ import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.net.InetAddress;
 import java.net.URLEncoder;
+import java.nio.CharBuffer;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -225,7 +226,7 @@ public class ExtendedAccessLogValve exte
         };
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             ElementTimestampStruct eds = currentDate.get();
             long millis = eds.currentTimestamp.getTime();
@@ -253,7 +254,7 @@ public class ExtendedAccessLogValve exte
         };
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             ElementTimestampStruct eds = currentTime.get();
             long millis = eds.currentTimestamp.getTime();
@@ -275,7 +276,7 @@ public class ExtendedAccessLogValve exte
             this.header = header;
         }
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             buf.append(wrap(request.getHeader(header)));
         }
@@ -289,7 +290,7 @@ public class ExtendedAccessLogValve exte
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             buf.append(wrap(response.getHeader(header)));
         }
@@ -302,7 +303,7 @@ public class ExtendedAccessLogValve exte
             this.attribute = attribute;
         }
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             buf.append(wrap(request.getContext().getServletContext()
                     .getAttribute(attribute)));
@@ -316,7 +317,7 @@ public class ExtendedAccessLogValve exte
             this.name = name;
         }
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             Cookie[] c = request.getCookies();
             for (int i = 0; c != null && i < c.length; i++) {
@@ -338,7 +339,7 @@ public class ExtendedAccessLogValve exte
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             if (null != response) {
                 Iterator<String> iter = response.getHeaders(header).iterator();
@@ -367,7 +368,7 @@ public class ExtendedAccessLogValve exte
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             buf.append(wrap(request.getAttribute(attribute)));
         }
@@ -380,7 +381,7 @@ public class ExtendedAccessLogValve exte
             this.attribute = attribute;
         }
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             HttpSession session = null;
             if (request != null) {
@@ -414,7 +415,7 @@ public class ExtendedAccessLogValve exte
         }
 
         @Override
-        public void addElement(StringBuilder buf, Date date, Request request,
+        public void addElement(CharBuffer buf, Date date, Request request,
                 Response response, long time) {
             buf.append(wrap(urlEncode(request.getParameter(parameter))));
         }
@@ -616,7 +617,7 @@ public class ExtendedAccessLogValve exte
             } else if ("dns".equals(nextToken)) {
                 return new AccessLogElement() {
                     @Override
-                    public void addElement(StringBuilder buf, Date date,
+                    public void addElement(CharBuffer buf, Date date,
                             Request request, Response response, long time) {
                         String value;
                         try {
@@ -656,7 +657,7 @@ public class ExtendedAccessLogValve exte
                     } else if ("query".equals(token)) {
                         return new AccessLogElement() {
                             @Override
-                            public void addElement(StringBuilder buf, Date date,
+                            public void addElement(CharBuffer buf, Date date,
                                     Request request, Response response,
                                     long time) {
                                 String query = request.getQueryString();
@@ -671,7 +672,7 @@ public class ExtendedAccessLogValve exte
                 } else {
                     return new AccessLogElement() {
                         @Override
-                        public void addElement(StringBuilder buf, Date date,
+                        public void addElement(CharBuffer buf, Date date,
                                 Request request, Response response, long time) {
                             String query = request.getQueryString();
                             if (query == null) {
@@ -778,7 +779,7 @@ public class ExtendedAccessLogValve exte
         if ("authType".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getAuthType()));
                 }
@@ -786,7 +787,7 @@ public class ExtendedAccessLogValve exte
         } else if ("remoteUser".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getRemoteUser()));
                 }
@@ -794,7 +795,7 @@ public class ExtendedAccessLogValve exte
         } else if ("requestedSessionId".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getRequestedSessionId()));
                 }
@@ -802,7 +803,7 @@ public class ExtendedAccessLogValve exte
         } else if ("requestedSessionIdFromCookie".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(""
                             + request.isRequestedSessionIdFromCookie()));
@@ -811,7 +812,7 @@ public class ExtendedAccessLogValve exte
         } else if ("requestedSessionIdValid".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap("" + request.isRequestedSessionIdValid()));
                 }
@@ -819,7 +820,7 @@ public class ExtendedAccessLogValve exte
         } else if ("contentLength".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap("" + request.getContentLength()));
                 }
@@ -827,7 +828,7 @@ public class ExtendedAccessLogValve exte
         } else if ("characterEncoding".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getCharacterEncoding()));
                 }
@@ -835,7 +836,7 @@ public class ExtendedAccessLogValve exte
         } else if ("locale".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getLocale()));
                 }
@@ -843,7 +844,7 @@ public class ExtendedAccessLogValve exte
         } else if ("protocol".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap(request.getProtocol()));
                 }
@@ -851,7 +852,7 @@ public class ExtendedAccessLogValve exte
         } else if ("scheme".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(request.getScheme());
                 }
@@ -859,7 +860,7 @@ public class ExtendedAccessLogValve exte
         } else if ("secure".equals(parameter)) {
             return new AccessLogElement() {
                 @Override
-                public void addElement(StringBuilder buf, Date date,
+                public void addElement(CharBuffer buf, Date date,
                         Request request, Response response, long time) {
                     buf.append(wrap("" + request.isSecure()));
                 }

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/AbstractProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/AbstractProtocol.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/AbstractProtocol.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/AbstractProtocol.java Wed Sep 26 20:35:24 2012
@@ -19,7 +19,6 @@ package org.apache.coyote;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
@@ -35,6 +34,7 @@ import org.apache.coyote.http11.upgrade.
 import org.apache.coyote.http11.upgrade.UpgradeProcessor;
 import org.apache.juli.logging.Log;
 import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.collections.SynchronizedStack;
 import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.AbstractEndpoint.Handler;
@@ -157,6 +157,24 @@ public abstract class AbstractProtocol i
     }
 
 
+    @Override
+    public boolean isCometSupported() {
+        return endpoint.getUseComet();
+    }
+
+
+    @Override
+    public boolean isCometTimeoutSupported() {
+        return endpoint.getUseCometTimeout();
+    }
+
+
+    @Override
+    public boolean isSendfileSupported() {
+        return endpoint.getUseSendfile();
+    }
+
+
     // ---------------------- Properties that are passed through to the EndPoint
 
     @Override
@@ -577,7 +595,7 @@ public abstract class AbstractProtocol i
 
             try {
                 if (processor == null) {
-                    processor = recycledProcessors.poll();
+                    processor = recycledProcessors.pop();
                 }
                 if (processor == null) {
                     processor = createProcessor();
@@ -732,9 +750,8 @@ public abstract class AbstractProtocol i
     }
 
     protected static class RecycledProcessors<P extends Processor<S>, S>
-            extends ConcurrentLinkedQueue<Processor<S>> {
+            extends SynchronizedStack<Processor<S>> {
 
-        private static final long serialVersionUID = 1L;
         private final transient AbstractConnectionHandler<S,P> handler;
         protected final AtomicInteger size = new AtomicInteger(0);
 
@@ -743,13 +760,13 @@ public abstract class AbstractProtocol i
         }
 
         @Override
-        public boolean offer(Processor<S> processor) {
+        public boolean push(Processor<S> processor) {
             int cacheSize = handler.getProtocol().getProcessorCache();
             boolean offer = cacheSize == -1 ? true : size.get() < cacheSize;
             //avoid over growing our cache or add after we have stopped
             boolean result = false;
             if (offer) {
-                result = super.offer(processor);
+                result = super.push(processor);
                 if (result) {
                     size.incrementAndGet();
                 }
@@ -759,8 +776,8 @@ public abstract class AbstractProtocol i
         }
 
         @Override
-        public Processor<S> poll() {
-            Processor<S> result = super.poll();
+        public Processor<S> pop() {
+            Processor<S> result = super.pop();
             if (result != null) {
                 size.decrementAndGet();
             }
@@ -769,10 +786,10 @@ public abstract class AbstractProtocol i
 
         @Override
         public void clear() {
-            Processor<S> next = poll();
+            Processor<S> next = pop();
             while (next != null) {
                 handler.unregister(next);
-                next = poll();
+                next = pop();
             }
             super.clear();
             size.set(0);

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/ProtocolHandler.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/ProtocolHandler.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/ProtocolHandler.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/ProtocolHandler.java Wed Sep 26 20:35:24 2012
@@ -88,4 +88,22 @@ public interface ProtocolHandler {
      * Requires APR/native library
      */
     public boolean isAprRequired();
+
+
+    /**
+     * Does this ProtocolHandler support Comet?
+     */
+    public boolean isCometSupported();
+
+
+    /**
+     * Does this ProtocolHandler support Comet timeouts?
+     */
+    public boolean isCometTimeoutSupported();
+
+
+    /**
+     * Does this ProtocolHandler support sendfile?
+     */
+    public boolean isSendfileSupported();
 }

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpAprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpAprProtocol.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpAprProtocol.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpAprProtocol.java Wed Sep 26 20:35:24 2012
@@ -131,7 +131,7 @@ public class AjpAprProtocol extends Abst
                 Processor<Long> processor, boolean isSocketClosing,
                 boolean addToPoller) {
             processor.recycle(isSocketClosing);
-            recycledProcessors.offer(processor);
+            recycledProcessors.push(processor);
             if (addToPoller) {
                 ((AprEndpoint)proto.endpoint).getPoller().add(
                         socket.getSocket().longValue(),

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpNioProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpNioProtocol.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpNioProtocol.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpNioProtocol.java Wed Sep 26 20:35:24 2012
@@ -149,7 +149,7 @@ public class AjpNioProtocol extends Abst
             Processor<NioChannel> processor = connections.remove(socket);
             if (processor != null) {
                 processor.recycle(true);
-                recycledProcessors.offer(processor);
+                recycledProcessors.push(processor);
             }
         }
 
@@ -162,7 +162,7 @@ public class AjpNioProtocol extends Abst
                 Processor<NioChannel> processor, boolean isSocketClosing,
                 boolean addToPoller) {
             processor.recycle(isSocketClosing);
-            recycledProcessors.offer(processor);
+            recycledProcessors.push(processor);
             if (addToPoller) {
                 socket.getSocket().getPoller().add(socket.getSocket());
             }

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpProtocol.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpProtocol.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/ajp/AjpProtocol.java Wed Sep 26 20:35:24 2012
@@ -125,7 +125,7 @@ public class AjpProtocol extends Abstrac
                 Processor<Socket> processor, boolean isSocketClosing,
                 boolean addToPoller) {
             processor.recycle(isSocketClosing);
-            recycledProcessors.offer(processor);
+            recycledProcessors.push(processor);
         }
 
 

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/AbstractHttp11Processor.java Wed Sep 26 20:35:24 2012
@@ -159,42 +159,6 @@ public abstract class AbstractHttp11Proc
     protected int keepAliveTimeout = -1;
 
     /**
-     * Remote Address associated with the current connection.
-     */
-    protected String remoteAddr = null;
-
-
-    /**
-     * Remote Host associated with the current connection.
-     */
-    protected String remoteHost = null;
-
-
-    /**
-     * Local Host associated with the current connection.
-     */
-    protected String localName = null;
-
-
-    /**
-     * Local port to which the socket is connected
-     */
-    protected int localPort = -1;
-
-
-    /**
-     * Remote port to which the socket is connected
-     */
-    protected int remotePort = -1;
-
-
-    /**
-     * The local Host address.
-     */
-    protected String localAddr = null;
-
-
-    /**
      * Maximum timeout on uploads. 5 minutes as in Apache HTTPD server.
      */
     protected int connectionUploadTimeout = 300000;
@@ -1279,26 +1243,6 @@ public abstract class AbstractHttp11Proc
             contentDelimitation = true;
         }
 
-        // Advertise sendfile support through a request attribute
-        if (endpoint.getUseSendfile()) {
-            request.setAttribute(
-                    org.apache.coyote.Constants.SENDFILE_SUPPORTED_ATTR,
-                    Boolean.TRUE);
-        }
-
-        // Advertise comet support through a request attribute
-        if (endpoint.getUseComet()) {
-            request.setAttribute(
-                    org.apache.coyote.Constants.COMET_SUPPORTED_ATTR,
-                    Boolean.TRUE);
-        }
-        // Advertise comet timeout support
-        if (endpoint.getUseCometTimeout()) {
-            request.setAttribute(
-                    org.apache.coyote.Constants.COMET_TIMEOUT_SUPPORTED_ATTR,
-                    Boolean.TRUE);
-        }
-
         if (error) {
             getAdapter().log(request, response, 0);
         }
@@ -1682,12 +1626,6 @@ public abstract class AbstractHttp11Proc
             asyncStateMachine.recycle();
         }
         upgradeInbound = null;
-        remoteAddr = null;
-        remoteHost = null;
-        localAddr = null;
-        localName = null;
-        remotePort = -1;
-        localPort = -1;
         comet = false;
         recycleInternal();
     }

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11AprProcessor.java Wed Sep 26 20:35:24 2012
@@ -278,87 +278,110 @@ public class Http11AprProcessor extends 
 
         if (actionCode == ActionCode.REQ_HOST_ADDR_ATTRIBUTE) {
 
-            // Get remote host address
-            if (remoteAddr == null && (socketRef != 0)) {
-                try {
-                    long sa = Address.get(Socket.APR_REMOTE, socketRef);
-                    remoteAddr = Address.getip(sa);
-                } catch (Exception e) {
-                    log.warn(sm.getString("http11processor.socket.info"), e);
+            if (socketRef == 0) {
+                request.remoteAddr().recycle();
+            } else {
+                if (socket.getRemoteAddr() == null) {
+                    try {
+                        long sa = Address.get(Socket.APR_REMOTE, socketRef);
+                        socket.setRemoteAddr(Address.getip(sa));
+                    } catch (Exception e) {
+                        log.warn(sm.getString("http11processor.socket.info"), e);
+                    }
                 }
+                request.remoteAddr().setString(socket.getRemoteAddr());
             }
-            request.remoteAddr().setString(remoteAddr);
 
         } else if (actionCode == ActionCode.REQ_LOCAL_NAME_ATTRIBUTE) {
 
-            // Get local host name
-            if (localName == null && (socketRef != 0)) {
-                try {
-                    long sa = Address.get(Socket.APR_LOCAL, socketRef);
-                    localName = Address.getnameinfo(sa, 0);
-                } catch (Exception e) {
-                    log.warn(sm.getString("http11processor.socket.info"), e);
+            if (socketRef == 0) {
+                request.localName().recycle();
+            } else {
+                if (socket.getLocalName() == null) {
+                    try {
+                        long sa = Address.get(Socket.APR_LOCAL, socketRef);
+                        socket.setLocalName(Address.getnameinfo(sa, 0));
+                    } catch (Exception e) {
+                        log.warn(sm.getString("http11processor.socket.info"), e);
+                    }
                 }
+                request.localName().setString(socket.getLocalName());
             }
-            request.localName().setString(localName);
 
         } else if (actionCode == ActionCode.REQ_HOST_ATTRIBUTE) {
 
-            // Get remote host name
-            if (remoteHost == null && (socketRef != 0)) {
-                try {
-                    long sa = Address.get(Socket.APR_REMOTE, socketRef);
-                    remoteHost = Address.getnameinfo(sa, 0);
-                    if (remoteHost == null) {
-                        remoteHost = Address.getip(sa);
+            if (socketRef == 0) {
+                request.remoteHost().recycle();
+            } else {
+                if (socket.getRemoteHost() == null) {
+                    try {
+                        long sa = Address.get(Socket.APR_REMOTE, socketRef);
+                        socket.setRemoteHost(Address.getnameinfo(sa, 0));
+                        if (socket.getRemoteHost() == null) {
+                            if (socket.getRemoteAddr() == null) {
+                                socket.setRemoteAddr(Address.getip(sa));
+                            }
+                            if (socket.getRemoteAddr() != null) {
+                                socket.setRemoteHost(socket.getRemoteAddr());
+                            }
+                        }
+                    } catch (Exception e) {
+                        log.warn(sm.getString("http11processor.socket.info"), e);
                     }
-                } catch (Exception e) {
-                    log.warn(sm.getString("http11processor.socket.info"), e);
+                } else {
+                    request.remoteHost().setString(socket.getRemoteHost());
                 }
             }
-            request.remoteHost().setString(remoteHost);
 
         } else if (actionCode == ActionCode.REQ_LOCAL_ADDR_ATTRIBUTE) {
 
-            // Get local host address
-            if (localAddr == null && (socketRef != 0)) {
-                try {
-                    long sa = Address.get(Socket.APR_LOCAL, socketRef);
-                    localAddr = Address.getip(sa);
-                } catch (Exception e) {
-                    log.warn(sm.getString("http11processor.socket.info"), e);
+            if (socketRef == 0) {
+                request.localAddr().recycle();
+            } else {
+                if (socket.getLocalAddr() == null) {
+                    try {
+                        long sa = Address.get(Socket.APR_LOCAL, socketRef);
+                        socket.setLocalAddr(Address.getip(sa));
+                    } catch (Exception e) {
+                        log.warn(sm.getString("http11processor.socket.info"), e);
+                    }
                 }
+                request.localAddr().setString(socket.getLocalAddr());
             }
 
-            request.localAddr().setString(localAddr);
-
         } else if (actionCode == ActionCode.REQ_REMOTEPORT_ATTRIBUTE) {
 
-            // Get remote port
-            if (remotePort == -1 && (socketRef != 0)) {
-                try {
-                    long sa = Address.get(Socket.APR_REMOTE, socketRef);
-                    Sockaddr addr = Address.getInfo(sa);
-                    remotePort = addr.port;
-                } catch (Exception e) {
-                    log.warn(sm.getString("http11processor.socket.info"), e);
+            if (socketRef == 0) {
+                request.setRemotePort(0);
+            } else {
+                if (socket.getRemotePort() == -1) {
+                    try {
+                        long sa = Address.get(Socket.APR_REMOTE, socketRef);
+                        Sockaddr addr = Address.getInfo(sa);
+                        socket.setRemotePort(addr.port);
+                    } catch (Exception e) {
+                        log.warn(sm.getString("http11processor.socket.info"), e);
+                    }
                 }
+                request.setRemotePort(socket.getRemotePort());
             }
-            request.setRemotePort(remotePort);
 
         } else if (actionCode == ActionCode.REQ_LOCALPORT_ATTRIBUTE) {
 
-            // Get local port
-            if (localPort == -1 && (socketRef != 0)) {
-                try {
-                    long sa = Address.get(Socket.APR_LOCAL, socketRef);
-                    Sockaddr addr = Address.getInfo(sa);
-                    localPort = addr.port;
-                } catch (Exception e) {
-                    log.warn(sm.getString("http11processor.socket.info"), e);
+            if (socketRef == 0) {
+                request.setLocalPort(0);
+            } else {
+                if (socket.getLocalPort() == -1) {
+                    try {
+                        long sa = Address.get(Socket.APR_LOCAL, socketRef);
+                        Sockaddr addr = Address.getInfo(sa);
+                        socket.setLocalPort(addr.port);
+                    } catch (Exception e) {
+                        log.warn(sm.getString("http11processor.socket.info"), e);
+                    }
                 }
+                request.setLocalPort(socket.getLocalPort());
             }
-            request.setLocalPort(localPort);
 
         } else if (actionCode == ActionCode.REQ_SSL_ATTRIBUTE ) {
 

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11AprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11AprProtocol.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11AprProtocol.java Wed Sep 26 20:35:24 2012
@@ -247,7 +247,7 @@ public class Http11AprProtocol extends A
                 Processor<Long> processor, boolean isSocketClosing,
                 boolean addToPoller) {
             processor.recycle(isSocketClosing);
-            recycledProcessors.offer(processor);
+            recycledProcessors.push(processor);
             if (addToPoller && proto.endpoint.isRunning()) {
                 ((AprEndpoint)proto.endpoint).getPoller().add(
                         socket.getSocket().longValue(),

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11NioProcessor.java Wed Sep 26 20:35:24 2012
@@ -397,65 +397,88 @@ public class Http11NioProcessor extends 
 
         if (actionCode == ActionCode.REQ_HOST_ADDR_ATTRIBUTE) {
 
-            // Get remote host address
-            if ((remoteAddr == null) && (socket != null)) {
-                InetAddress inetAddr = socket.getSocket().getIOChannel().socket().getInetAddress();
-                if (inetAddr != null) {
-                    remoteAddr = inetAddr.getHostAddress();
+            if (socket == null) {
+                request.remoteAddr().recycle();
+            } else {
+                if (socket.getRemoteAddr() == null) {
+                    InetAddress inetAddr = socket.getSocket().getIOChannel().socket().getInetAddress();
+                    if (inetAddr != null) {
+                        socket.setRemoteAddr(inetAddr.getHostAddress());
+                    }
                 }
+                request.remoteAddr().setString(socket.getRemoteAddr());
             }
-            request.remoteAddr().setString(remoteAddr);
 
         } else if (actionCode == ActionCode.REQ_LOCAL_NAME_ATTRIBUTE) {
 
-            // Get local host name
-            if ((localName == null) && (socket != null)) {
-                InetAddress inetAddr = socket.getSocket().getIOChannel().socket().getLocalAddress();
-                if (inetAddr != null) {
-                    localName = inetAddr.getHostName();
+            if (socket == null) {
+                request.localName().recycle();
+            } else {
+                if (socket.getLocalName() == null) {
+                    InetAddress inetAddr = socket.getSocket().getIOChannel().socket().getLocalAddress();
+                    if (inetAddr != null) {
+                        socket.setLocalName(inetAddr.getHostName());
+                    }
                 }
+                request.localName().setString(socket.getLocalName());
             }
-            request.localName().setString(localName);
 
         } else if (actionCode == ActionCode.REQ_HOST_ATTRIBUTE) {
 
-            // Get remote host name
-            if ((remoteHost == null) && (socket != null)) {
-                InetAddress inetAddr = socket.getSocket().getIOChannel().socket().getInetAddress();
-                if (inetAddr != null) {
-                    remoteHost = inetAddr.getHostName();
-                }
-                if(remoteHost == null) {
-                    if(remoteAddr != null) {
-                        remoteHost = remoteAddr;
-                    } else { // all we can do is punt
-                        request.remoteHost().recycle();
+            if (socket == null) {
+                request.remoteHost().recycle();
+            } else {
+                if (socket.getRemoteHost() == null) {
+                    InetAddress inetAddr = socket.getSocket().getIOChannel().socket().getInetAddress();
+                    if (inetAddr != null) {
+                        socket.setRemoteHost(inetAddr.getHostName());
+                    }
+                    if (socket.getRemoteHost() == null) {
+                        if (socket.getRemoteAddr() == null &&
+                                inetAddr != null) {
+                            socket.setRemoteAddr(inetAddr.getHostAddress());
+                        }
+                        if (socket.getRemoteAddr() != null) {
+                            socket.setRemoteHost(socket.getRemoteAddr());
+                        }
                     }
                 }
+                request.remoteHost().setString(socket.getRemoteHost());
             }
-            request.remoteHost().setString(remoteHost);
 
         } else if (actionCode == ActionCode.REQ_LOCAL_ADDR_ATTRIBUTE) {
 
-            if (localAddr == null) {
-                localAddr = socket.getSocket().getIOChannel().socket().getLocalAddress().getHostAddress();
+            if (socket == null) {
+                request.localAddr().recycle();
+            } else {
+                if (socket.getLocalAddr() == null) {
+                    socket.setLocalAddr(
+                            socket.getSocket().getIOChannel().socket().getLocalAddress().getHostAddress());
+                }
+                request.localAddr().setString(socket.getLocalAddr());
             }
 
-            request.localAddr().setString(localAddr);
-
         } else if (actionCode == ActionCode.REQ_REMOTEPORT_ATTRIBUTE) {
 
-            if ((remotePort == -1 ) && (socket !=null)) {
-                remotePort = socket.getSocket().getIOChannel().socket().getPort();
+            if (socket == null) {
+                request.setRemotePort(0);
+            } else {
+                if (socket.getRemotePort() == -1) {
+                    socket.setRemotePort(socket.getSocket().getIOChannel().socket().getPort());
+                }
+                request.setRemotePort(socket.getRemotePort());
             }
-            request.setRemotePort(remotePort);
 
         } else if (actionCode == ActionCode.REQ_LOCALPORT_ATTRIBUTE) {
 
-            if ((localPort == -1 ) && (socket !=null)) {
-                localPort = socket.getSocket().getIOChannel().socket().getLocalPort();
+            if (socket == null) {
+                request.setLocalPort(0);
+            } else {
+                if (socket.getLocalPort() == -1) {
+                    socket.setLocalPort(socket.getSocket().getIOChannel().socket().getLocalPort());
+                }
+                request.setLocalPort(socket.getLocalPort());
             }
-            request.setLocalPort(localPort);
 
         } else if (actionCode == ActionCode.REQ_SSL_ATTRIBUTE ) {
 

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11NioProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11NioProtocol.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11NioProtocol.java Wed Sep 26 20:35:24 2012
@@ -207,7 +207,7 @@ public class Http11NioProtocol extends A
                 connections.remove(socket.getSocket());
             if (processor != null) {
                 processor.recycle(true);
-                recycledProcessors.offer(processor);
+                recycledProcessors.push(processor);
             }
         }
 
@@ -238,7 +238,7 @@ public class Http11NioProtocol extends A
                 Processor<NioChannel> processor, boolean isSocketClosing,
                 boolean addToPoller) {
             processor.recycle(isSocketClosing);
-            recycledProcessors.offer(processor);
+            recycledProcessors.push(processor);
             if (addToPoller) {
                 socket.getSocket().getPoller().add(socket.getSocket());
             }

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11Processor.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11Processor.java Wed Sep 26 20:35:24 2012
@@ -273,61 +273,88 @@ public class Http11Processor extends Abs
 
         } else if (actionCode == ActionCode.REQ_HOST_ADDR_ATTRIBUTE) {
 
-            if ((remoteAddr == null) && (socket != null)) {
-                InetAddress inetAddr = socket.getSocket().getInetAddress();
-                if (inetAddr != null) {
-                    remoteAddr = inetAddr.getHostAddress();
+            if (socket == null) {
+                request.remoteAddr().recycle();
+            } else {
+                if (socket.getRemoteAddr() == null) {
+                    InetAddress inetAddr = socket.getSocket().getInetAddress();
+                    if (inetAddr != null) {
+                        socket.setRemoteAddr(inetAddr.getHostAddress());
+                    }
                 }
+                request.remoteAddr().setString(socket.getRemoteAddr());
             }
-            request.remoteAddr().setString(remoteAddr);
 
         } else if (actionCode == ActionCode.REQ_LOCAL_NAME_ATTRIBUTE) {
 
-            if ((localName == null) && (socket != null)) {
-                InetAddress inetAddr = socket.getSocket().getLocalAddress();
-                if (inetAddr != null) {
-                    localName = inetAddr.getHostName();
+            if (socket == null) {
+                request.localName().recycle();
+            } else {
+                if (socket.getLocalName() == null) {
+                    InetAddress inetAddr = socket.getSocket().getLocalAddress();
+                    if (inetAddr != null) {
+                        socket.setLocalName(inetAddr.getHostName());
+                    }
                 }
+                request.localName().setString(socket.getLocalName());
             }
-            request.localName().setString(localName);
 
         } else if (actionCode == ActionCode.REQ_HOST_ATTRIBUTE) {
 
-            if ((remoteHost == null) && (socket != null)) {
-                InetAddress inetAddr = socket.getSocket().getInetAddress();
-                if (inetAddr != null) {
-                    remoteHost = inetAddr.getHostName();
-                }
-                if(remoteHost == null) {
-                    if(remoteAddr != null) {
-                        remoteHost = remoteAddr;
-                    } else { // all we can do is punt
-                        request.remoteHost().recycle();
+            if (socket == null) {
+                request.remoteHost().recycle();
+            } else {
+                if (socket.getRemoteHost() == null) {
+                    InetAddress inetAddr = socket.getSocket().getInetAddress();
+                    if (inetAddr != null) {
+                        socket.setRemoteHost(inetAddr.getHostName());
+                    }
+                    if (socket.getRemoteHost() == null) {
+                        if (socket.getRemoteAddr() == null &&
+                                inetAddr != null) {
+                            socket.setRemoteAddr(inetAddr.getHostAddress());
+                        }
+                        if (socket.getRemoteAddr() != null) {
+                            socket.setRemoteHost(socket.getRemoteAddr());
+                        }
                     }
                 }
+                request.remoteHost().setString(socket.getRemoteHost());
             }
-            request.remoteHost().setString(remoteHost);
 
         } else if (actionCode == ActionCode.REQ_LOCAL_ADDR_ATTRIBUTE) {
 
-            if (localAddr == null)
-               localAddr = socket.getSocket().getLocalAddress().getHostAddress();
-
-            request.localAddr().setString(localAddr);
+            if (socket == null) {
+                request.localAddr().recycle();
+            } else {
+                if (socket.getLocalAddr() == null) {
+                    socket.setLocalAddr(
+                            socket.getSocket().getLocalAddress().getHostAddress());
+                }
+                request.localAddr().setString(socket.getLocalAddr());
+            }
 
         } else if (actionCode == ActionCode.REQ_REMOTEPORT_ATTRIBUTE) {
 
-            if ((remotePort == -1 ) && (socket !=null)) {
-                remotePort = socket.getSocket().getPort();
+            if (socket == null) {
+                request.setRemotePort(0);
+            } else {
+                if (socket.getRemotePort() == -1) {
+                    socket.setRemotePort(socket.getSocket().getPort());
+                }
+                request.setRemotePort(socket.getRemotePort());
             }
-            request.setRemotePort(remotePort);
 
         } else if (actionCode == ActionCode.REQ_LOCALPORT_ATTRIBUTE) {
 
-            if ((localPort == -1 ) && (socket !=null)) {
-                localPort = socket.getSocket().getLocalPort();
+            if (socket == null) {
+                request.setLocalPort(0);
+            } else {
+                if (socket.getLocalPort() == -1) {
+                    socket.setLocalPort(socket.getSocket().getLocalPort());
+                }
+                request.setLocalPort(socket.getLocalPort());
             }
-            request.setLocalPort(localPort);
 
         } else if (actionCode == ActionCode.REQ_SSL_CERTIFICATE) {
             if( sslSupport != null) {

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11Protocol.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11Protocol.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/Http11Protocol.java Wed Sep 26 20:35:24 2012
@@ -159,7 +159,7 @@ public class Http11Protocol extends Abst
                 Processor<Socket> processor, boolean isSocketClosing,
                 boolean addToPoller) {
             processor.recycle(isSocketClosing);
-            recycledProcessors.offer(processor);
+            recycledProcessors.push(processor);
         }
 
         @Override

Modified: tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/InternalNioOutputBuffer.java?rev=1390718&r1=1390717&r2=1390718&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/InternalNioOutputBuffer.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/coyote/http11/InternalNioOutputBuffer.java Wed Sep 26 20:35:24 2012
@@ -375,9 +375,7 @@ public class InternalNioOutputBuffer ext
 
     private int transfer(byte[] from, int offset, int length, ByteBuffer to) {
         int max = Math.min(length, to.remaining());
-        ByteBuffer tmp = ByteBuffer.wrap(from, offset, max);
-        tmp.limit (tmp.position() + max);
-        to.put (tmp);
+        to.put(from, offset, max);
         return max;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message