[logback-dev] [JIRA] Commented: (LBCLASSIC-36) Synchronization of SimpleDateFormat object in DateConverter

Ceki Gulcu (JIRA) noreply-jira at qos.ch
Sun Jun 14 22:01:10 CEST 2009

    [ http://jira.qos.ch/browse/LBCLASSIC-36?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11180#action_11180 ] 

Ceki Gulcu commented on LBCLASSIC-36:

I modified DateFormatPerftest in ch.qos.logback.classic.issue.lbclassic36 so as to take into account the kind of millisecond cache that we would keep. This is reflected in the "guarded" versions of the various methods.

Here is a sample result.

Raw Joda:      average tick 2792.437593 nanoseconds
Raw SDF:       average tick 2147.457408 nanoseconds
Guarded Joda:  average tick 138.560775 nanoseconds
Guarded SDF:   average tick 73.691388 nanoseconds

The guarded SDF version is very quick (less than 100 nanos) and is probably the code that will be used in the future. Please let me know if you see any faults or downsides to this proposal.

> Synchronization of SimpleDateFormat object in DateConverter
> -----------------------------------------------------------
>                 Key: LBCLASSIC-36
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-36
>             Project: logback-classic
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: unspecified
>         Environment: Operating System: All
> Platform: All
>            Reporter: Anders Hammar
>            Assignee: Ceki Gulcu
>         Attachments: DateConverter_patch.java, dateformattest.zip
> According to the API documentation of SimpleDateFormat, date formats are not synchronized and it is recommended to create separate format instances for each thread.
> However, a possibly simpler (mer efficient) solution would be to synchronize on the SimpleDateFormat object in the convert() method to prevent two threads to access it concurrently.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the logback-dev mailing list