Bug 56595 - Review synchronization in DateUtil.isADateFormat(), replace with ThreadLocals?
Summary: Review synchronization in DateUtil.isADateFormat(), replace with ThreadLocals?
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.11-dev
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-05 20:15 UTC by Dominik Stadler
Modified: 2014-12-22 12:09 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominik Stadler 2014-06-05 20:15:14 UTC
Copied over comment after resolving Bug 56563 (likely a result of caching/synchronization added in Bug 55611):

----
Note that every call to DateUtil.isCellDateFormatted(a-numeric-cell) ends up in a call to DateUtil.isADateFormat() which itself also maintains a static cache of the last result and synchronizes on DateUtil.class.

In my case for example, the issue with the formatString arises by a call to DateUtil.isCellDateFormatted(cell), so I still get monitor locks upon each call even though you use thread locals for the style formatString cache. 

Seems like it would be a good idea to use the same strategy and switch the DateUtil.isADateFormat() cache to be ThreadLocal based rather than synchronization based.
----
Comment 1 Dominik Stadler 2014-12-22 12:09:35 UTC
We now switched the cache in DateUtil.isADateFormat() to ThreadLocals as well to not have another syncpoint here. 

Again only very little data is kept, so no memory bloat should happen because of this.

See r1647296 for details.