DrobotDenya / openid4java

Automatically exported from code.google.com/p/openid4java
Apache License 2.0
0 stars 0 forks source link

HashMap usage with InMemoryConsumerAssociationStore, InMemoryServerAssociationStore can cause infinite loops. #174

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
HashMaps are currently used to store associations in these classes; while the 
.save()/.generate()/.load() methods are each individually synchronized, actual 
concurrent access between a reader and writer of the hashmap is not protected 
in any way.  If the HashMap is modified resulting in a resize of the HashMap, 
another thread performing a .load() operation concurrently could loop 
indefinitely as a result.  A ConcurrentHashMap implementation should be used 
instead to prevent this form of condition from occurring.

Original issue reported on code.google.com by matthew....@gmail.com on 16 Jan 2012 at 7:27

GoogleCodeExporter commented 8 years ago
The synchronization is not applied individually on each method, the lock is the 
association store object - so a reader and a writer cannot simultaneously 
access the store and its private hashmap (which is not leaked outside the 
object for others to access).

Was the behavior described actually observed? If so - a test case or steps to 
reproduce would help.

Original comment by Johnny.B...@gmail.com on 30 Oct 2012 at 10:26