geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1145907 - in /geronimo/external/trunk/tomcat-parent-7.0.18: catalina/src/main/java/org/apache/catalina/connector/ catalina/src/main/java/org/apache/catalina/core/ catalina/src/main/java/org/apache/catalina/servlets/ catalina/src/main/java/...
Date Wed, 13 Jul 2011 08:48:04 GMT
Author: xuhaihong
Date: Wed Jul 13 08:48:03 2011
New Revision: 1145907

URL: http://svn.apache.org/viewvc?rev=1145907&view=rev
Log:
Merge Tomcat changes to rev1145694

Modified:
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/core/StandardContextValve.java
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/servlets/DefaultServlet.java
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/servlets/WebdavServlet.java
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/util/RequestUtil.java
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/valves/AccessLogValve.java
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/catalina/valves/LocalStrings.properties
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/catalina/valves/mbeans-descriptors.xml
    geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/coyote/http11/LocalStrings.properties
    geronimo/external/trunk/tomcat-parent-7.0.18/juli/src/main/java/org/apache/juli/FileHandler.java

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java
Wed Jul 13 08:48:03 2011
@@ -493,8 +493,24 @@ public class CoyoteAdapter implements Ad
         }
         
         try {
-            connector.getService().getContainer().logAccess(
-                    request, response, time, true);
+            // Log at the lowest level available. logAccess() will be
+            // automatically called on parent containers.
+            boolean logged = false;
+            if (request.mappingData != null) {
+                if (request.mappingData.context != null) {
+                    logged = true;
+                    ((Context) request.mappingData.context).logAccess(
+                            request, response, time, true);
+                } else if (request.mappingData.host != null) {
+                    logged = true;
+                    ((Context) request.mappingData.context).logAccess(
+                            request, response, time, true);
+                }
+            }
+            if (!logged) {
+                connector.getService().getContainer().logAccess(
+                        request, response, time, true);
+            }
         } catch (Throwable t) {
             ExceptionUtils.handleThrowable(t);
             log.warn(sm.getString("coyoteAdapter.accesslogFail"), t);

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/core/StandardContextValve.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/core/StandardContextValve.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/core/StandardContextValve.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/core/StandardContextValve.java
Wed Jul 13 08:48:03 2011
@@ -180,7 +180,12 @@ final class StandardContextValve
             // place
             if (!(request.isAsync() || (asyncAtStart && request.getAttribute(
                         RequestDispatcher.ERROR_EXCEPTION) != null))) {
-                context.fireRequestDestroyEvent(request);
+                // Protect against NPEs if context was destroyed during a long
+                // running request.
+                StandardContext c = context;
+                if (c != null && c.getState().isAvailable()) {
+                    context.fireRequestDestroyEvent(request);
+                }
             }
         }
     }

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/servlets/DefaultServlet.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/servlets/DefaultServlet.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/servlets/DefaultServlet.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/servlets/DefaultServlet.java
Wed Jul 13 08:48:03 2011
@@ -1659,7 +1659,6 @@ public class DefaultServlet
                 request.setAttribute("org.apache.tomcat.sendfile.start", Long.valueOf(range.start));
                 request.setAttribute("org.apache.tomcat.sendfile.end", Long.valueOf(range.end
+ 1));
             }
-            request.setAttribute("org.apache.tomcat.sendfile.token", this);
             return true;
         }
         return false;

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/servlets/WebdavServlet.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/servlets/WebdavServlet.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/servlets/WebdavServlet.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/servlets/WebdavServlet.java
Wed Jul 13 08:48:03 2011
@@ -200,7 +200,7 @@ public class WebdavServlet
      * Simple date format for the creation date ISO representation (partial).
      */
     protected static final SimpleDateFormat creationDateFormat =
-        new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+        new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
 
 
      /**

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/util/RequestUtil.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/util/RequestUtil.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/util/RequestUtil.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/util/RequestUtil.java
Wed Jul 13 08:48:03 2011
@@ -20,9 +20,7 @@ package org.apache.catalina.util;
 
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
-import java.text.SimpleDateFormat;
 import java.util.Map;
-import java.util.TimeZone;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -48,16 +46,6 @@ public final class RequestUtil {
      */
     private static final StringManager sm =
         StringManager.getManager("org.apache.catalina.util");
-    
-    /**
-     * The DateFormat to use for generating readable dates in cookies.
-     */
-    private static SimpleDateFormat format =
-        new SimpleDateFormat(" EEEE, dd-MMM-yy kk:mm:ss zz");
-
-    static {
-        format.setTimeZone(TimeZone.getTimeZone("GMT"));
-    }
 
 
     /**
@@ -207,8 +195,10 @@ public final class RequestUtil {
                 }
                 parseParameters(map, bytes, encoding);
             } catch (UnsupportedEncodingException uee) {
-                log.debug(sm.getString("requestUtil.parseParameters.uee",
-                        encoding), uee);
+                if (log.isDebugEnabled()) {
+                    log.debug(sm.getString("requestUtil.parseParameters.uee",
+                            encoding), uee);
+                }
             }
 
         }
@@ -271,7 +261,9 @@ public final class RequestUtil {
                 bytes = str.getBytes(B2CConverter.getCharset(enc));
             }
         } catch (UnsupportedEncodingException uee) {
-            log.debug(sm.getString("requestUtil.urlDecode.uee", enc), uee);
+            if (log.isDebugEnabled()) {
+                log.debug(sm.getString("requestUtil.urlDecode.uee", enc), uee);
+            }
         }
 
         return URLDecode(bytes, enc, isQuery);
@@ -341,7 +333,9 @@ public final class RequestUtil {
             try {
                 return new String(bytes, 0, ox, B2CConverter.getCharset(enc));
             } catch (UnsupportedEncodingException uee) {
-                log.debug(sm.getString("requestUtil.urlDecode.uee", enc), uee);
+                if (log.isDebugEnabled()) {
+                    log.debug(sm.getString("requestUtil.urlDecode.uee", enc), uee);
+                }
                 return null;
             }
         }
@@ -458,7 +452,4 @@ public final class RequestUtil {
         }
 
     }
-
-
-
 }

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/valves/AccessLogValve.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/valves/AccessLogValve.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/valves/AccessLogValve.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/valves/AccessLogValve.java
Wed Jul 13 08:48:03 2011
@@ -21,10 +21,13 @@ package org.apache.catalina.valves;
 
 import java.io.BufferedWriter;
 import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 import java.net.InetAddress;
+import java.nio.charset.Charset;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -32,6 +35,7 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.TimeZone;
 
 import javax.servlet.ServletException;
@@ -48,6 +52,7 @@ import org.apache.coyote.RequestInfo;
 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;
 
 
 /**
@@ -249,6 +254,12 @@ public class AccessLogValve extends Valv
      * format) and a HashMap of caches for additional formats used by
      * SimpleDateFormat.</p>
      *
+     * <p>Although the cache supports specifying a locale when retrieving a
+     * formatted timestamp, each format will always use the locale given
+     * when the format was first used. New locales can only be used for new formats.
+     * The CLF format will always be formatted using the locale
+     * <code>en_US</code>.</p>
+     *
      * <p>The cache is not threadsafe. It can be used without synchronization
      * via thread local instances, or with synchronization as a global cache.</p>
      *
@@ -285,21 +296,34 @@ public class AccessLogValve extends Valv
 
             private Cache parent = null;
 
+            private Cache(Cache parent) {
+                this(null, parent);
+            }
+
             private Cache(String format, Cache parent) {
+                this(format, null, parent);
+            }
+
+            private Cache(String format, Locale loc, Cache parent) {
                 cache = new String[cacheSize];
                 for (int i = 0; i < cacheSize; i++) {
                     cache[i] = null;
                 }
+                if (loc == null) {
+                    loc = cacheDefaultLocale;
+                }
                 if (format == null) {
                     isCLF = true;
                     format = cLFFormat;
+                    formatter = new SimpleDateFormat(format, Locale.US);
+                } else {
+                    formatter = new SimpleDateFormat(format, loc);
                 }
-                formatter = new SimpleDateFormat(format);
                 formatter.setTimeZone(TimeZone.getDefault());
                 this.parent = parent;
             }
 
-            private String getFormat(long time) {
+            private String getFormatInternal(long time) {
 
                 long seconds = time / 1000;
 
@@ -349,7 +373,7 @@ public class AccessLogValve extends Valv
                  * parent cache or locally. */
                 if (parent != null) {
                     synchronized(parent) {
-                        previousFormat = parent.getFormat(time);
+                        previousFormat = parent.getFormatInternal(time);
                     }
                 } else {
                     currentDate.setTime(time);
@@ -372,23 +396,25 @@ public class AccessLogValve extends Valv
         /* Number of cached entries */
         private int cacheSize = 0;
 
+        private Locale cacheDefaultLocale;
         private DateFormatCache parent;
         private Cache cLFCache;
         private HashMap<String, Cache> formatCache = new HashMap<String, Cache>();
 
-        private DateFormatCache(int size, DateFormatCache parent) {
+        private DateFormatCache(int size, Locale loc, DateFormatCache parent) {
             cacheSize = size;
+            cacheDefaultLocale = loc;
             this.parent = parent;
             Cache parentCache = null;
             if (parent != null) {
                 synchronized(parent) {
-                    parentCache = parent.getCache(null);
+                    parentCache = parent.getCache(null, null);
                 }
             }
-            cLFCache = new Cache(null, parentCache);
+            cLFCache = new Cache(parentCache);
         }
 
-        private Cache getCache(String format) {
+        private Cache getCache(String format, Locale loc) {
             Cache cache;
             if (format == null) {
                 cache = cLFCache;
@@ -398,19 +424,22 @@ public class AccessLogValve extends Valv
                     Cache parentCache = null;
                     if (parent != null) {
                         synchronized(parent) {
-                            parentCache = parent.getCache(format);
+                            parentCache = parent.getCache(format, loc);
                         }
                     }
-                    cache = new Cache(format, parentCache);
+                    cache = new Cache(format, loc, parentCache);
                     formatCache.put(format, cache);
                 }
             }
             return cache;
         }
 
-        public String getFormat(String format, long time) {
+        public String getFormat(long time) {
+            return cLFCache.getFormatInternal(time);
+        }
 
-            return getCache(format).getFormat(time);
+        public String getFormat(String format, Locale loc, long time) {
+            return getCache(format, loc).getFormatInternal(time);
         }
     }
 
@@ -418,7 +447,7 @@ public class AccessLogValve extends Valv
      * Global date format cache.
      */
     private static final DateFormatCache globalDateCache =
-            new DateFormatCache(globalCacheSize, null);
+            new DateFormatCache(globalCacheSize, Locale.getDefault(), null);
 
     /**
      * Thread local date format cache.
@@ -427,7 +456,7 @@ public class AccessLogValve extends Valv
             new ThreadLocal<DateFormatCache>() {
         @Override
         protected DateFormatCache initialValue() {
-            return new DateFormatCache(localCacheSize, globalDateCache);
+            return new DateFormatCache(localCacheSize, Locale.getDefault(), globalDateCache);
         }
     };
 
@@ -479,7 +508,28 @@ public class AccessLogValve extends Valv
      * Date format to place in log file name. Use at your own risk!
      */
     protected String fileDateFormat = null;
-    
+
+
+    /**
+     * Name of locale used to format timestamps in log entries and in
+     * log file name suffix.
+     */
+    protected String localeName = Locale.getDefault().toString();
+
+
+    /**
+     * Locale used to format timestamps in log entries and in
+     * log file name suffix.
+     */
+    protected Locale locale = Locale.getDefault();
+
+    /**
+     * Character set used by the log file. If it is <code>null</code>, the
+     * system default character set will be used. An empty string will be
+     * treated as <code>null</code> when this property is assigned.
+     */
+    protected String encoding = null;
+
     /**
      * Array of AccessLogElement, they will be used to make log message.
      */
@@ -708,6 +758,7 @@ public class AccessLogValve extends Valv
         this.condition = condition;
     }
 
+
     /**
      *  Return the date format date based log rotation.
      */
@@ -723,6 +774,52 @@ public class AccessLogValve extends Valv
         this.fileDateFormat =  fileDateFormat;
     }
 
+
+    /**
+     * Return the locale used to format timestamps in log entries and in
+     * log file name suffix.
+     */
+    public String getLocale() {
+        return localeName;
+    }
+
+
+    /**
+     * Set the locale used to format timestamps in log entries and in
+     * log file name suffix. Changing the locale is only supported
+     * as long as the AccessLogValve has not logged anything. Changing
+     * the locale later can lead to inconsistent formatting.
+     *
+     * @param localeName The locale to use.
+     */
+    public void setLocale(String localeName) {
+        this.localeName = localeName;
+        locale = findLocale(localeName, locale);
+    }
+
+    /**
+     * Return the character set name that is used to write the log file.
+     *
+     * @return Character set name, or <code>null</code> if the system default
+     *  character set is used.
+     */
+    public String getEncoding() {
+        return encoding;
+    }
+
+    /**
+     * Set the character set that is used to write the log file.
+     * 
+     * @param encoding The name of the character set.
+     */
+    public void setEncoding(String encoding) {
+        if (encoding != null && encoding.length() > 0) {
+            this.encoding = encoding;
+        } else {
+            this.encoding = null;
+        }
+    }
+
     // --------------------------------------------------------- Public Methods
 
     /**
@@ -911,23 +1008,44 @@ public class AccessLogValve extends Valv
         }
 
         // Open the current log file
-        try {
-            String pathname;
-            // If no rotate - no need for dateStamp in fileName
-            if (rotatable) {
-                pathname = dir.getAbsolutePath() + File.separator + prefix
-                        + dateStamp + suffix;
-            } else {
-                pathname = dir.getAbsolutePath() + File.separator + prefix
-                        + suffix;
+        File pathname;
+        // If no rotate - no need for dateStamp in fileName
+        if (rotatable) {
+            pathname = new File(dir.getAbsoluteFile(), prefix + dateStamp
+                    + suffix);
+        } else {
+            pathname = new File(dir.getAbsoluteFile(), prefix + suffix);
+        }
+        File parent = pathname.getParentFile();
+        if (!parent.exists()) {
+            if (!parent.mkdirs()) {
+                log.error(sm.getString("accessLogValve.openDirFail", parent));
             }
-            writer = new PrintWriter(new BufferedWriter(new FileWriter(
-                    pathname, true), 128000), false);
-            
-            currentLogFile = new File(pathname);
+        }
+
+        Charset charset = null;
+        if (encoding != null) {
+            try {
+                charset = B2CConverter.getCharset(encoding);
+            } catch (UnsupportedEncodingException ex) {
+                log.error(sm.getString(
+                        "accessLogValve.unsupportedEncoding", encoding), ex);
+            }
+        }
+        if (charset == null) {
+            charset = Charset.defaultCharset();
+        }
+
+        try {
+            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
+                    new FileOutputStream(pathname, true), charset), 128000),
+                    false);
+
+            currentLogFile = pathname;
         } catch (IOException e) {
             writer = null;
             currentLogFile = null;
+            log.error(sm.getString("accessLogValve.openFail", pathname), e);
         }
     }
  
@@ -979,6 +1097,23 @@ public class AccessLogValve extends Valv
         return tz.toString();
     }
 
+    /**
+     * Find a locale by name
+     */
+    protected static Locale findLocale(String name, Locale fallback) {
+        if (name == null || name.isEmpty()) {
+            return Locale.getDefault();
+        } else {
+            for (Locale l: Locale.getAvailableLocales()) {
+                if (name.equals(l.toString())) {
+                    return(l);
+                }
+            }
+        }
+        log.error(sm.getString("accessLogValve.invalidLocale", name));
+        return fallback;
+    }
+
     static {
         // Initialize the timeZone
         timezone = TimeZone.getDefault();
@@ -1004,7 +1139,7 @@ public class AccessLogValve extends Valv
             format = "yyyy-MM-dd";
             setFileDateFormat(format);
         }
-        fileDateFormatter = new SimpleDateFormat(format);
+        fileDateFormatter = new SimpleDateFormat(format, Locale.US);
         fileDateFormatter.setTimeZone(timezone);
         dateStamp = fileDateFormatter.format(new Date(System.currentTimeMillis()));
         open();
@@ -1252,7 +1387,6 @@ public class AccessLogValve extends Valv
                     escape = !escape;
                 }
             }
-            format = result.toString();
         }
 
         protected DateAndTimeElement(String header) {
@@ -1296,7 +1430,7 @@ public class AccessLogValve extends Valv
             }
             switch (type) {
             case CLF:
-                buf.append(localDateCache.get().getFormat(null, timestamp));
+                buf.append(localDateCache.get().getFormat(timestamp));
                 break;
             case SEC:
                 buf.append(timestamp / 1000);
@@ -1317,7 +1451,7 @@ public class AccessLogValve extends Valv
                 buf.append(frac);
                 break;
             case SDF:
-                String temp = localDateCache.get().getFormat(format, timestamp);
+                String temp = localDateCache.get().getFormat(format, locale, timestamp);
                 if (usesMsecs) {
                     frac = timestamp % 1000;
                     StringBuilder trippleMsec = new StringBuilder(4);

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/valves/ExtendedAccessLogValve.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
Wed Jul 13 08:48:03 2011
@@ -28,6 +28,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.TimeZone;
 
 import javax.servlet.http.Cookie;
@@ -875,7 +876,7 @@ public class ExtendedAccessLogValve exte
         private String currentTimestampString;
         
         ElementTimestampStruct(String format) {
-            currentTimestampFormat = new SimpleDateFormat(format);
+            currentTimestampFormat = new SimpleDateFormat(format, Locale.US);
             currentTimestampFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
         }
     }

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java
Wed Jul 13 08:48:03 2011
@@ -305,7 +305,18 @@ public class Http11AprProcessor extends 
                 sendfileData.socket = socketRef;
                 sendfileData.keepAlive = keepAlive;
                 if (!((AprEndpoint)endpoint).getSendfile().add(sendfileData)) {
-                    openSocket = true;
+                    if (sendfileData.socket == 0) {
+                        // Didn't send all the data but the socket is no longer
+                        // set. Something went wrong. Close the connection.
+                        // Too late to set status code.
+                        if (log.isDebugEnabled()) {
+                            log.debug(sm.getString(
+                                    "http11processor.sendfile.error"));
+                        }
+                        error = true;
+                    } else {
+                        openSocket = true;
+                    }
                     break;
                 }
             }

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java
Wed Jul 13 08:48:03 2011
@@ -471,24 +471,55 @@ public class AprEndpoint extends Abstrac
             }
 
             // SSL protocol
-            int value = SSL.SSL_PROTOCOL_ALL;
-            if ("SSLv2".equalsIgnoreCase(SSLProtocol)) {
-                value = SSL.SSL_PROTOCOL_SSLV2;
-            } else if ("SSLv3".equalsIgnoreCase(SSLProtocol)) {
-                value = SSL.SSL_PROTOCOL_SSLV3;
-            } else if ("TLSv1".equalsIgnoreCase(SSLProtocol)) {
-                value = SSL.SSL_PROTOCOL_TLSV1;
-            } else if ("SSLv2+SSLv3".equalsIgnoreCase(SSLProtocol)) {
-                value = SSL.SSL_PROTOCOL_SSLV2 | SSL.SSL_PROTOCOL_SSLV3;
-            } else if ("all".equalsIgnoreCase(SSLProtocol) ||
-                    SSLProtocol == null || SSLProtocol.length() == 0) {
-                // NOOP, use the default defined above
+            int value;
+            // This branch can be removed, once the required version is at least 1.1.21.
+            int tcnFullVersion = Library.TCN_MAJOR_VERSION * 1000
+                    + Library.TCN_MINOR_VERSION * 100
+                    + Library.TCN_PATCH_VERSION;
+            if (tcnFullVersion <= 1120) {
+                value = SSL.SSL_PROTOCOL_ALL;
+                if ("SSLv2".equalsIgnoreCase(SSLProtocol)) {
+                    value = SSL.SSL_PROTOCOL_SSLV2;
+                } else if ("SSLv3".equalsIgnoreCase(SSLProtocol)) {
+                    value = SSL.SSL_PROTOCOL_SSLV3;
+                } else if ("TLSv1".equalsIgnoreCase(SSLProtocol)) {
+                    value = SSL.SSL_PROTOCOL_TLSV1;
+                } else if ("SSLv2+SSLv3".equalsIgnoreCase(SSLProtocol)) {
+                    value = SSL.SSL_PROTOCOL_SSLV2 | SSL.SSL_PROTOCOL_SSLV3;
+                } else if ("all".equalsIgnoreCase(SSLProtocol) ||
+                        SSLProtocol == null || SSLProtocol.length() == 0) {
+                    // NOOP, use the default defined above
+                } else {
+                    // Protocol not recognized, fail to start as it is safer than
+                    // continuing with the default which might enable more than the
+                    // is required
+                    throw new Exception(sm.getString(
+                            "endpoint.apr.invalidSslProtocol", SSLProtocol));
+                }
             } else {
-                // Protocol not recognized, fail to start as it is safer than
-                // continuing with the default which might enable more than the
-                // is required
-                throw new Exception(sm.getString(
-                        "endpoint.apr.invalidSslProtocol", SSLProtocol));
+                value = SSL.SSL_PROTOCOL_NONE;
+                if (SSLProtocol == null || SSLProtocol.length() == 0) {
+                    value = SSL.SSL_PROTOCOL_ALL;
+                } else {
+                        for (String protocol : SSLProtocol.split("\\+")) {
+                        protocol = protocol.trim();
+                        if ("SSLv2".equalsIgnoreCase(protocol)) {
+                            value |= SSL.SSL_PROTOCOL_SSLV2;
+                        } else if ("SSLv3".equalsIgnoreCase(protocol)) {
+                            value |= SSL.SSL_PROTOCOL_SSLV3;
+                        } else if ("TLSv1".equalsIgnoreCase(protocol)) {
+                            value |= SSL.SSL_PROTOCOL_TLSV1;
+                        } else if ("all".equalsIgnoreCase(protocol)) {
+                            value |= SSL.SSL_PROTOCOL_ALL;
+                        } else {
+                            // Protocol not recognized, fail to start as it is safer than
+                            // continuing with the default which might enable more than the
+                            // is required
+                            throw new Exception(sm.getString(
+                                    "endpoint.apr.invalidSslProtocol", SSLProtocol));
+                        }
+                    }
+                }
             }
 
             // Create SSL Context
@@ -1429,7 +1460,9 @@ public class AprEndpoint extends Abstrac
                                                data.pos, data.end - data.pos, 0);
                     if (nw < 0) {
                         if (!(-nw == Status.EAGAIN)) {
-                            destroySocket(data.socket);
+                            Pool.destroy(data.fdpool);
+                            // No need to close socket, this will be done by
+                            // calling code since data.socket == 0
                             data.socket = 0;
                             return false;
                         } else {

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
Wed Jul 13 08:48:03 2011
@@ -1240,6 +1240,13 @@ public class NioEndpoint extends Abstrac
                         sd.pos += written;
                         sd.length -= written;
                         attachment.access();
+                    } else {
+                        // Unusual not to be able to transfer any bytes
+                        // Check the length was set correctly
+                        if (sd.fchannel.size() <= sd.pos) {
+                            throw new IOException("Sendfile configured to " +
+                                    "send more data than was available");
+                        }
                     }
                 }
                 if ( sd.length <= 0 && sc.getOutboundRemaining()<=0) {
@@ -1264,6 +1271,7 @@ public class NioEndpoint extends Abstrac
                             log.debug("Send file connection is being closed");
                         }
                         cancelledKey(sk,SocketStatus.STOP,false);
+                        return false;
                     }
                 } else if ( attachment.interestOps() == 0 && reg ) {
                     if (log.isDebugEnabled()) {

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/catalina/valves/LocalStrings.properties
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/catalina/valves/LocalStrings.properties?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/catalina/valves/LocalStrings.properties
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/catalina/valves/LocalStrings.properties
Wed Jul 13 08:48:03 2011
@@ -22,9 +22,12 @@ cometConnectionManagerValve.event=Except
 cometConnectionManagerValve.listenerEvent=Exception processing session listener event
 
 # Access log valve
-accessLogValve.closeFail=Failed to close log file
+accessLogValve.openFail=Failed to open access log file [{0}]
+accessLogValve.closeFail=Failed to close access log file
 accessLogValve.openDirFail=Failed to create directory [{0}] for access logs
 accessLogValve.rotateFail=Failed to rotate access log
+accessLogValve.invalidLocale=Failed to set locale to [{0}]
+accessLogValve.unsupportedEncoding=Failed to set encoding to [{0}], will use the system default
character set.
 
 # Error report valve
 errorReportValve.errorReport=Error report

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/catalina/valves/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/catalina/valves/mbeans-descriptors.xml?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/catalina/valves/mbeans-descriptors.xml
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/catalina/valves/mbeans-descriptors.xml
Wed Jul 13 08:48:03 2011
@@ -46,26 +46,34 @@
     <attribute name="condition"
                description="The value to look for conditional logging."
                type="java.lang.String"/>
-               
+
     <attribute name="directory"
                description="The directory in which log files are created"
                type="java.lang.String"/>
-               
+
     <attribute name="enabled"
                description="Enable Access Logging"
                is="false"
                type="boolean"/>
 
+    <attribute name="encoding"
+               description="Character set used to write the log file"
+               type="java.lang.String"/>
+
     <attribute name="fileDateFormat"
-               description="The format for the date date based log rotation."
+               description="The format for the date for date based log rotation"
                type="java.lang.String"/>
-               
+
     <attribute name="info"
                description="Information about this implementation"
                type="java.lang.String"
                writeable="false"/>
 
-    <attribute   name="pattern"
+    <attribute name="locale"
+               description="The locale used to format timestamps in the access log lines"
+               type="java.lang.String"/>
+
+    <attribute name="pattern"
                description="The pattern used to format our access log lines"
                type="java.lang.String"/>
 
@@ -198,25 +206,33 @@
     <attribute name="condition"
                description="The value to look for conditional logging."
                type="java.lang.String"/>
-               
+
     <attribute name="directory"
                description="The directory in which log files are created"
                type="java.lang.String"/>
-               
-     <attribute name="enabled"
+
+    <attribute name="enabled"
                description="Enable Access Logging"
                is="false"
                type="boolean"/>
 
+    <attribute name="encoding"
+               description="Character set used to write the log file"
+               type="java.lang.String"/>
+
     <attribute name="fileDateFormat"
                description="The format for the date date based log rotation."
                type="java.lang.String"/>
-               
+
     <attribute name="info"
                description="Information about this implementation"
                type="java.lang.String"
                writeable="false"/>
 
+    <attribute name="locale"
+               description="The locale used to format timestamps in the access log lines"
+               type="java.lang.String"/>
+
     <attribute   name="pattern"
                description="The pattern used to format our access log lines"
                type="java.lang.String"/>

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/coyote/http11/LocalStrings.properties
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/coyote/http11/LocalStrings.properties?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/coyote/http11/LocalStrings.properties
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/catalina/src/main/resources/org/apache/coyote/http11/LocalStrings.properties
Wed Jul 13 08:48:03 2011
@@ -34,6 +34,8 @@ http11processor.socket.info=Exception ge
 http11processor.socket.ssl=Exception getting SSL attributes
 http11processor.socket.sslreneg=Exception re-negotiating SSL connection
 http11processor.socket.timeout=Error setting socket timeout
+http11processor.comet.notsupported=The Comet protocol is not supported by this connector
+http11processor.sendfile.error=Error sending data using sendfile. May be caused by invalid
request attributes for start/end points
 
 iib.eof.error=Unexpected EOF read on the socket
 iib.requestheadertoolarge.error=Request header is too large

Modified: geronimo/external/trunk/tomcat-parent-7.0.18/juli/src/main/java/org/apache/juli/FileHandler.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.18/juli/src/main/java/org/apache/juli/FileHandler.java?rev=1145907&r1=1145906&r2=1145907&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.18/juli/src/main/java/org/apache/juli/FileHandler.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.18/juli/src/main/java/org/apache/juli/FileHandler.java
Wed Jul 13 08:48:03 2011
@@ -367,8 +367,12 @@ public class FileHandler
         // Open the current log file
         writerLock.writeLock().lock();
         try {
-            String pathname = dir.getAbsolutePath() + File.separator +
-                prefix + (rotatable ? date : "") + suffix;
+            File pathname = new File(dir.getAbsoluteFile(), prefix
+                    + (rotatable ? date : "") + suffix);
+            File parent = pathname.getParentFile();
+            if (!parent.exists()) {
+                parent.mkdirs();
+            }
             String encoding = getEncoding();
             FileOutputStream fos = new FileOutputStream(pathname, true);
             OutputStream os = bufferSize>0?new BufferedOutputStream(fos,bufferSize):fos;



Mime
View raw message