[#1071] Remove Attribute from map after Attribute.remove() was called
This commit is contained in:
parent
43ff36cef0
commit
6568cbfec4
@ -49,8 +49,7 @@ public interface Attribute<T> {
|
|||||||
boolean compareAndSet(T oldValue, T newValue);
|
boolean compareAndSet(T oldValue, T newValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the current value which is stored in this {@link Attribute}, which means after this call {@link #get()}
|
* Remove this attribute from the {@link AttributeMap}.
|
||||||
* will return {@code null}.
|
|
||||||
*/
|
*/
|
||||||
void remove();
|
void remove();
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class DefaultAttributeMap implements AttributeMap {
|
|||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class DefaultAttribute<T> extends AtomicReference<T> implements Attribute<T> {
|
private final class DefaultAttribute<T> extends AtomicReference<T> implements Attribute<T> {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2661411462200283011L;
|
private static final long serialVersionUID = -2661411462200283011L;
|
||||||
|
|
||||||
@ -62,7 +62,9 @@ public class DefaultAttributeMap implements AttributeMap {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
set(null);
|
synchronized (DefaultAttributeMap.this) {
|
||||||
|
map.remove(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user