Hello,
I have a class which stores session specific data with
session.setAttribute(SessionState.STATE_KEY, ss);
But this contains data like (CharsetEncoder) which usage should not be
interleaved
by doDecode and encode. Since the communication rate for each session is
not very high
i came up with an easy fix:
@Override
public void messageReceived(IoSession session, Object message)
throws Exception {
SessionState ss = (SessionState)
session.getAttribute(SessionState.STATE_KEY);
synchronized(ss.lock) {
super.messageReceived(session, message);
}
}
@Override
public void messageSent(IoSession session, Object message) throws
Exception {
SessionState ss = (SessionState)
session.getAttribute(SessionState.STATE_KEY);
synchronized(ss.lock) {
super.messageSent(session, message);
}
}
I wondering if this is a good idea, or a big no-no. For my purpose it
does not need to be perfect
in efficiency terms, but i dont want any deadlocks and stuff.
regards