luehe 2004/08/05 18:27:50
Modified: catalina/src/share/org/apache/catalina/connector
Request.java
Log:
Avoid allocating SimpleDateFormat[] for each request. Instead, declare
SimpleDateFormat[] as static and use static initializer to initialize it.
This is consistent with SimpleDateFormat[] in
org.apache.tomcat.util.http.FastHttpDateFormat.
Revision Changes Path
1.11 +23 -25
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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Request.java 3 Aug 2004 19:42:38 -0000 1.10
+++ Request.java 6 Aug 2004 01:27:50 -0000 1.11
@@ -82,18 +82,6 @@
implements HttpServletRequest {
- // ----------------------------------------------------------- Constructors
-
-
- public Request() {
-
- formats[0].setTimeZone(TimeZone.getTimeZone("GMT"));
- formats[1].setTimeZone(TimeZone.getTimeZone("GMT"));
- formats[2].setTimeZone(TimeZone.getTimeZone("GMT"));
-
- }
-
-
// ------------------------------------------------------------- Properties
@@ -120,7 +108,27 @@
}
- // ----------------------------------------------------- Instance Variables
+ // ----------------------------------------------------- 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);
+ }
/**
@@ -137,16 +145,6 @@
/**
- * The set of SimpleDateFormat formats to use in getDateHeader().
- */
- 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();
@@ -1767,7 +1765,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]