Fixed issue: NETTY-382 ChannelLocal.remove() should return the return

value of initialValue() instead of null when no value was set.
This commit is contained in:
Trustin Lee 2011-02-22 16:54:25 +09:00
parent 31b257f6f2
commit 0859ff782e

View File

@ -110,14 +110,23 @@ public class ChannelLocal<T> {
}
/**
* Removes the variable.
* Removes the variable and returns the removed value. If no value was set,
* this method returns the return value of {@link #initialValue(Channel)},
* which is {@code null} by default.
*
* @return the removed value. {@code null} if no value was set.
* @return the removed value.
* {@linkplain #initialValue(Channel) an initial value} (by default
* {@code null}) if no value was set.
*/
public T remove(Channel channel) {
if (channel == null) {
throw new NullPointerException("channel");
}
return map.remove(channel);
T removed = map.remove(channel);
if (removed == null) {
return initialValue(channel);
} else {
return removed;
}
}
}