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:
parent
1f35e7c99b
commit
76660f4a98
|
@ -536,11 +536,13 @@ public class HashCodeBuilder {
|
||||||
* @since 2.3
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
static void unregister(Object value) {
|
static void unregister(Object value) {
|
||||||
Set<IDKey> s = getRegistry();
|
Set<IDKey> registry = getRegistry();
|
||||||
if (s != null) {
|
if (registry != null) {
|
||||||
s.remove(new IDKey(value));
|
registry.remove(new IDKey(value));
|
||||||
synchronized (HashCodeBuilder.class) {
|
synchronized (HashCodeBuilder.class) {
|
||||||
if (s.isEmpty()) {
|
//read again
|
||||||
|
registry = getRegistry();
|
||||||
|
if (registry != null && registry.isEmpty()) {
|
||||||
REGISTRY.remove();
|
REGISTRY.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue