reread ThreadLocal value in synchronized block to avoid any timing issues

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@907375 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2010-02-07 03:42:08 +00:00
parent 1f35e7c99b
commit 76660f4a98
1 changed files with 6 additions and 4 deletions

View File

@ -536,11 +536,13 @@ public class HashCodeBuilder {
* @since 2.3
*/
static void unregister(Object value) {
Set<IDKey> s = getRegistry();
if (s != null) {
s.remove(new IDKey(value));
Set<IDKey> registry = getRegistry();
if (registry != null) {
registry.remove(new IDKey(value));
synchronized (HashCodeBuilder.class) {
if (s.isEmpty()) {
//read again
registry = getRegistry();
if (registry != null && registry.isEmpty()) {
REGISTRY.remove();
}
}