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:
parent
31b257f6f2
commit
0859ff782e
@ -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) {
|
public T remove(Channel channel) {
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
throw new NullPointerException("channel");
|
throw new NullPointerException("channel");
|
||||||
}
|
}
|
||||||
return map.remove(channel);
|
T removed = map.remove(channel);
|
||||||
|
if (removed == null) {
|
||||||
|
return initialValue(channel);
|
||||||
|
} else {
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user