Bug 44627 - [PATCH] POILogFactory thread safety issue
Summary: [PATCH] POILogFactory thread safety issue
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.0-dev
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-03-18 09:05 UTC by Mike Flester
Modified: 2008-03-19 05:51 UTC (History)
1 user (show)

svn diff text for POILogFactory thread safety issue (2.27 KB, patch)
2008-03-18 09:05 UTC, Mike Flester
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Flester 2008-03-18 09:05:12 UTC
Created attachment 21678 [details]
svn diff text for POILogFactory thread safety issue

POILogFactory is not threadsafe and even with the default NullLogger I am getting JVM lockups in a multi-threaded environment. Since the POILogger property is really only used for debugging POI itself according to the docs, I provide a patch that makes the default (i.e. no logger specified) operation thread safe.
Alternatively the entire mechanism could be made threadsafe by switching the map in POILogFactory from a HashMap to a Hashtable, or synchronizing the getLogger method. Since it is rarely used, that seemed a little heavy handed to propose initially.

The patch is svn diff text. The only file modified is POILogFactory.
Comment 1 Nick Burch 2008-03-19 05:51:00 UTC
Thanks for the patch. I've ended up applying something slightly similar, as shifting the environment variable fetching back to class initialisation did break some things. Hopefully it now works just fine for you.

I believe the new version is now completely thread safe when using NullLogger. The rest ought to be thread safe, but not always thread efficient (as it's possible that two thread will both create their own loggers for something, but one overwrites the others)