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 { ...@@ -206,13 +206,14 @@ public class MINAStatCollector {
// add the bytes processed between last polling and session closing // add the bytes processed between last polling and session closing
// prevent non seen byte with non-connected protocols like HTTP and datagrams // prevent non seen byte with non-connected protocols like HTTP and datagrams
IoSessionStat sessStat = ( IoSessionStat ) session.getAttribute( KEY ); IoSessionStat sessStat = ( IoSessionStat ) session.removeAttribute( KEY );
session.removeAttribute( KEY );
totalMsgWritten.addAndGet(session.getWrittenMessages() - sessStat.lastMessageWrite); if (sessStat != null) {
totalMsgRead.addAndGet(session.getReadMessages() - sessStat.lastMessageRead); totalMsgWritten.addAndGet(session.getWrittenMessages() - sessStat.lastMessageWrite);
totalBytesWritten.addAndGet(session.getWrittenBytes() - sessStat.lastByteWrite); totalMsgRead.addAndGet(session.getReadMessages() - sessStat.lastMessageRead);
totalBytesRead.addAndGet(session.getReadBytes() - sessStat.lastByteRead); 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