The netty documentation suggests using instance variables in ChannelHandlers to track channel status. He does not mention that you should use mutable variables or use any other synchronization technique to ensure that threads are always displayed.
For example, using this handler for each connection:
class Handler extends SimpleChannelUpstreamHandler { int count = 0; @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { ++count; } }
I would expect that many different threads from the netty thread pool would call this method, although not at the same time, and could potentially see an inconsistent view, which leads to an inaccurate count.
This is true? or is there some kind of synchronization going on inside netty that will lead to painting the record in the count field?
source share