Bug 48922

Summary: org.apache.catalina.connector.Request clone static SimpleDateFormat
Product: Tomcat 6 Reporter: Ondrej Medek <xmedeko>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: default   
Hardware: All   
OS: All   
Attachments: Test performance creation of the Request() object
Requested changes added to the Request Class

Description Ondrej Medek 2010-03-16 14:33:18 UTC
Faster usage of the thread unsafe SimpleDateFormat is:

private static final SimpleDateFormat FORMAT_PROTOTYPE = new SimpleDateFormat("...", Locale.ROOT);
static {
  format.setTimeZone(GMT_ZONE);
}

protected SimpleDateFormat format = (SimpleDateFormat)FORMAT_PROTOTYPE.clone();

Please, apply this pattern to the formats[] field. It shoudl speed up the request processing a little bit.

Thanks
Comment 1 Daniel Lemon 2010-04-17 11:40:00 UTC
Created attachment 25317 [details]
Test performance creation of the Request() object
Comment 2 Daniel Lemon 2010-04-17 11:41:50 UTC
Created attachment 25318 [details]
Requested changes added to the Request Class

On my machine I saw an increase in roughly 12% of performance.
Comment 3 Mark Thomas 2016-03-14 16:49:39 UTC
Thanks for the patch.

Because Request objects are recycled this improvement will only apply on the creation of a Request object and even then the performance improvement is in the order of microseconds.

The patch has been applied to 9.0.x for 9.0.0.M5 onwards.