luehe       2004/08/09 15:55:00

  Modified:    catalina/src/share/org/apache/catalina/connector
                        Request.java
  Log:
  Reverted previous patch (except for keeping the GMT_ZONE constant),
  because SimpleDateFormat is not thread-safe and therefore cannot be
  declared as a static var.
  
  We could pass "null" to FastHttpDateFormat.parseDate(), in which case
  we would leverage FastHttpDateFormat's SimpleDateFormat[] constant,
  but this would mean that dates would be parsed within the synchronized
  block in FastHttpDateFormat.parseDate(), which may be costly.
  
  Revision  Changes    Path
  1.12      +26 -18    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/Request.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Request.java      6 Aug 2004 01:27:50 -0000       1.11
  +++ Request.java      9 Aug 2004 22:55:00 -0000       1.12
  @@ -82,6 +82,18 @@
       implements HttpServletRequest {
   
   
  +    // ----------------------------------------------------------- Constructors
  +
  +
  +    public Request() {
  +
  +        formats[0].setTimeZone(GMT_ZONE);
  +        formats[1].setTimeZone(GMT_ZONE);
  +        formats[2].setTimeZone(GMT_ZONE);
  +
  +    }
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -111,26 +123,9 @@
       // ----------------------------------------------------- Variables
   
   
  -    /**
  -     * The set of SimpleDateFormat formats to use in getDateHeader().
  -     */
  -    protected static final SimpleDateFormat FORMATS[] = {
  -        new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
  -        new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
  -        new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
  -    };
  -
  -
       protected static final TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT");
   
   
  -    static {
  -        FORMATS[0].setTimeZone(GMT_ZONE);
  -        FORMATS[1].setTimeZone(GMT_ZONE);
  -        FORMATS[2].setTimeZone(GMT_ZONE);
  -    }
  -
  -
       /**
        * The string manager for this package.
        */
  @@ -145,6 +140,19 @@
   
   
       /**
  +     * The set of SimpleDateFormat formats to use in getDateHeader().
  +     *
  +     * Notice that because SimpleDateFormat is not thread-safe, we can't
  +     * declare formats[] as a static variable.
  +     */
  +    protected SimpleDateFormat formats[] = {
  +        new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
  +        new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
  +        new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
  +    };
  +
  +
  +    /**
        * The default Locale if none are specified.
        */
       protected static Locale defaultLocale = Locale.getDefault();
  @@ -1765,7 +1773,7 @@
               return (-1L);
   
           // Attempt to convert the date header in a variety of formats
  -        long result = FastHttpDateFormat.parseDate(value, FORMATS);
  +        long result = FastHttpDateFormat.parseDate(value, formats);
           if (result != (-1L)) {
               return result;
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to