Bug 48922 - org.apache.catalina.connector.Request clone static SimpleDateFormat
Summary: org.apache.catalina.connector.Request clone static SimpleDateFormat
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Catalina (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement with 1 vote (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-16 14:33 UTC by Ondrej Medek
Modified: 2016-03-14 16:49 UTC (History)
0 users



Attachments
Test performance creation of the Request() object (3.53 KB, patch)
2010-04-17 11:40 UTC, Daniel Lemon
Details | Diff
Requested changes added to the Request Class (1.41 KB, patch)
2010-04-17 11:41 UTC, Daniel Lemon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.