Hi all,
We should add a method for remving a property from the context:
public static void removeProperty(IoSession session, String key) {
if (key == null) {
throw new NullPointerException("key should not be null");
}
Context context = getContext(session);
context.remove(key);
}
And maybe the option to immediately set the property in the MDC, since
in the current implementation, the property does not show up for log
statements generated during the handling of the current event.
Therefor I suggest adding this method:
public static void setProperty (IoSession session, String key,
String value, boolean immediate) {
if (key == null) {
throw new NullPointerException("key should not be null");
}
if (value == null) {
removeProperty(session, key);
}
Context context = getContext(session);
context.put(key, value);
if (immediate) {
MDC.put(key, value);
}
}
And a default value of true:
public static void setProperty (IoSession session, String key,
String value) {
setProperty(session, key, value, true);
}
I thought about checking the callDepth property instead of the extra
parameter, but the property isn't static. I think the extra parameter
is an acceptable solution.
WDYT ?
Maarten