private void updateReadBytesCounter(ChannelHandlerContext ctx) {
        ChannelTrafficShapingHandler handler = (ChannelTrafficShapingHandler) ctx.channel().pipeline().get(TRAFFIC_HANDLER_NAME);
        if (handler != null) {
            long currentBytes = handler.trafficCounter().currentReadBytes();
            Long prevBytes = ctx.channel().attr(READ_BYTES).get();
            long delta;
            if (prevBytes == null) {
                delta = currentBytes;
            }
            else {
                delta = currentBytes - prevBytes;
            }
            ctx.channel().attr(READ_BYTES).set(currentBytes);
            ctx.channel().attr(IDLE_FLAG).set(null);
            ServerTrafficCounter.incrementIncomingCounter(delta);
        }
    }
Updates the system counter of read bytes. This information is used by the incoming
bytes statistic.

@param ctx the context for the channel reading bytes
xmppserver/src/main/java/org/jivesoftware/openfire/nio/NettyConnectionHandler.java