hunterhacker/jdom — Issue #51: Namespace.getNamespace() has broken locking
Author: rolfl
Created: 2011-10-25 11:59:35+00:00
State: open

This method is supposed to ensure that only one Namespace instance exists for any prefix/URI combination, but there are gaps in the synchronization that allow duplicates to (potentially) happen.

Specifically, the code does a synchronized 'check' for the namespace, and if it is not there it creates the Namespace instance.
It then re-synchronizes on the lock, and adds the new Namespace instance.

But, if a concurrent thread is attempting to get the same Namespace, it may have already put it's instance on the Map between our thread's locks, and, thus that thread will have it's instance, and our thread, and subsequent threads will have a different instance.