Author: markt
Date: Mon Mar 14 16:47:32 2016
New Revision: 1734958
URL: http://svn.apache.org/viewvc?rev=1734958&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=48922
Apply a very small performance improvement to the date formatting in Tomcat's
internal request object.
Based on a patch provided by Ondrej Medek.
Modified:
tomcat/trunk/java/org/apache/catalina/connector/Request.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/catalina/connector/Request.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Request.java?rev=1734958&r1=1734957&r2=1734958&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Request.java Mon Mar 14
16:47:32 2016
@@ -127,11 +127,10 @@ public class Request implements HttpServ
public Request() {
-
- formats[0].setTimeZone(GMT_ZONE);
- formats[1].setTimeZone(GMT_ZONE);
- formats[2].setTimeZone(GMT_ZONE);
-
+ formats = new SimpleDateFormat[formatsTemplate.length];
+ for(int i = 0; i < formats.length; i++) {
+ formats[i] = (SimpleDateFormat) formatsTemplate[i].clone();
+ }
}
@@ -187,7 +186,9 @@ public class Request implements HttpServ
* Notice that because SimpleDateFormat is not thread-safe, we can't
* declare formats[] as a static variable.
*/
- protected final SimpleDateFormat formats[] = {
+ protected final SimpleDateFormat formats[];
+
+ private static final SimpleDateFormat formatsTemplate[] = {
new SimpleDateFormat(FastHttpDateFormat.RFC1123_DATE, 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)
@@ -3489,5 +3490,9 @@ public class Request implements HttpServ
// NO-OP
}
});
+
+ for (SimpleDateFormat sdf : formatsTemplate) {
+ sdf.setTimeZone(GMT_ZONE);
+ }
}
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1734958&r1=1734957&r2=1734958&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Mon Mar 14 16:47:32 2016
@@ -45,6 +45,15 @@
issues do not "pop up" wrt. others).
-->
<section name="Tomcat 9.0.0.M5" rtext="In development">
+ <subsection name="Catalina">
+ <changelog>
+ <fix>
+ <bug>48922</bug>: Apply a very small performance improvement to the
+ date formatting in Tomcat's internal request object. Based on a patch
+ provided by Ondrej Medek. (markt)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="Coyote">
<changelog>
<fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]