Commit c5d906a3 authored by Tom Evans's avatar Tom Evans

OF-878: NPE in MINAStatCollector

Fixes a race condition where (apparently) the removeSession method is
invoked before the addSession method has completed.
parent 6d0283c6
......@@ -206,13 +206,14 @@ public class MINAStatCollector {
// add the bytes processed between last polling and session closing
// prevent non seen byte with non-connected protocols like HTTP and datagrams
IoSessionStat sessStat = ( IoSessionStat ) session.getAttribute( KEY );
session.removeAttribute( KEY );
IoSessionStat sessStat = ( IoSessionStat ) session.removeAttribute( KEY );
totalMsgWritten.addAndGet(session.getWrittenMessages() - sessStat.lastMessageWrite);
totalMsgRead.addAndGet(session.getReadMessages() - sessStat.lastMessageRead);
totalBytesWritten.addAndGet(session.getWrittenBytes() - sessStat.lastByteWrite);
totalBytesRead.addAndGet(session.getReadBytes() - sessStat.lastByteRead);
if (sessStat != null) {
totalMsgWritten.addAndGet(session.getWrittenMessages() - sessStat.lastMessageWrite);
totalMsgRead.addAndGet(session.getReadMessages() - sessStat.lastMessageRead);
totalBytesWritten.addAndGet(session.getWrittenBytes() - sessStat.lastByteWrite);
totalBytesRead.addAndGet(session.getReadBytes() - sessStat.lastByteRead);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment