Author: remy.maucherat(a)jboss.com
Date: 2009-02-13 22:45:44 -0500 (Fri, 13 Feb 2009)
New Revision: 934
Modified:
branches/2.1.x/java/org/apache/tomcat/util/http/ServerCookie.java
branches/2.1.x/webapps/docs/changelog.xml
Log:
- v0 optimization.
Modified: branches/2.1.x/java/org/apache/tomcat/util/http/ServerCookie.java
===================================================================
--- branches/2.1.x/java/org/apache/tomcat/util/http/ServerCookie.java 2009-02-14 03:45:27
UTC (rev 933)
+++ branches/2.1.x/java/org/apache/tomcat/util/http/ServerCookie.java 2009-02-14 03:45:44
UTC (rev 934)
@@ -57,14 +57,20 @@
// Other fields
private static final String OLD_COOKIE_PATTERN =
"EEE, dd-MMM-yyyy HH:mm:ss z";
- private static final DateFormat OLD_COOKIE_FORMAT;
+ private static final ThreadLocal<DateFormat> OLD_COOKIE_FORMAT =
+ new ThreadLocal<DateFormat>() {
+ protected DateFormat initialValue() {
+ DateFormat df =
+ new SimpleDateFormat(OLD_COOKIE_PATTERN, Locale.US);
+ df.setTimeZone(TimeZone.getTimeZone("GMT"));
+ return df;
+ }
+ };
private static final String ancientDate;
static {
- OLD_COOKIE_FORMAT = new SimpleDateFormat(OLD_COOKIE_PATTERN, Locale.US);
- OLD_COOKIE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
- ancientDate = OLD_COOKIE_FORMAT.format(new Date(10000));
+ ancientDate = OLD_COOKIE_FORMAT.get().format(new Date(10000));
}
/**
@@ -306,16 +312,14 @@
// Wdy, DD-Mon-YY HH:MM:SS GMT ( Expires Netscape format )
buf.append ("; Expires=");
// To expire immediately we need to set the time in past
- if (maxAge == 0)
+ if (maxAge == 0) {
buf.append( ancientDate );
- else
- synchronized (OLD_COOKIE_FORMAT) {
- OLD_COOKIE_FORMAT.format(
- new Date(System.currentTimeMillis() +
- maxAge*1000L),
- buf, new FieldPosition(0));
- }
-
+ } else {
+ OLD_COOKIE_FORMAT.get().format(
+ new Date(System.currentTimeMillis() +
+ maxAge*1000L),
+ buf, new FieldPosition(0));
+ }
} else {
buf.append ("; Max-Age=");
buf.append (maxAge);
Modified: branches/2.1.x/webapps/docs/changelog.xml
===================================================================
--- branches/2.1.x/webapps/docs/changelog.xml 2009-02-14 03:45:27 UTC (rev 933)
+++ branches/2.1.x/webapps/docs/changelog.xml 2009-02-14 03:45:44 UTC (rev 934)
@@ -46,6 +46,9 @@
<fix>
HTTP/1.0 handling differed from the old org.apache.jk connector. (remm)
</fix>
+ <fix>
+ Optimize date format for v0 cookies. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
Show replies by date