Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 3.00, 3.01, 3.02, 3.03, 3.04, 3.05, 3.06
-
Fix Version/s: 3.07
-
Component/s: Referencing
-
Labels:
Description
When FactoryFinder.getCRSAuthorityFactory(...) is invoked extensively in a multi-thread environment, there is sometime a deadlock:
- AuthorityFactoryFinder.getCRSAuthorityFactory(...) holds a lock on AuthorityFactoryFinder.class
- ThreadedAuthorityFactory.availability() holds a lock on this
- Both of the above methods wait for the lock of the other one (indirectly, the call stack is somewhat deep).
The easy fix is to remove the synchronized statement on ThreadedAuthorityFactory.availability(), which was not strictly necessary since the method implementation was already thread-safe (provided that the status field is made volatile). The cost is that the same work may be done twice, but I don't think it will happen often in practice.
However we should take the opportunity for reducing a bit more the amount of locks, especially in createBackingStore(), because the later invoke client code that we may not control. Even in the case of Geotk implementation, the call stack is deep with recursive calls to FactoryFinder. We are safer to arrange the code in such a way that createBackingStore() is invoked outside any synchronized block.
