[#1071] Remove Attribute from map after Attribute.remove() was called

This commit is contained in:
Norman Maurer 2013-02-21 19:38:23 +01:00
parent 43ff36cef0
commit 6568cbfec4
2 changed files with 5 additions and 4 deletions

View File

@ -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();
} }

View File

@ -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);
}
} }
} }
} }