Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-1047

NullPointerException in AbstractIoSession.destroy()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.15
    • 2.0.16
    • Core
    • None
    • Any

    Description

      After upgrading to v2.0.15, we get this NPE ...

      java.lang.NullPointerException
      	at org.apache.mina.core.session.AbstractIoSession.destroy(AbstractIoSession.java:369)
      	at org.apache.mina.core.session.AbstractIoSession.closeNow(AbstractIoSession.java:350)
      	at org.apache.mina.core.session.DefaultIoSessionDataStructureFactory$DefaultWriteRequestQueue.poll(DefaultIoSessionDataStructureFactory.java:222)
      	at org.apache.mina.core.polling.AbstractPollingIoProcessor.flushNow(AbstractPollingIoProcessor.java:827)
      	at org.apache.mina.core.polling.AbstractPollingIoProcessor.flush(AbstractPollingIoProcessor.java:767)
      	at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$700(AbstractPollingIoProcessor.java:68)
      	at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1125)
      	at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      If I'm reading it right, the destroy also needs to allow that the writeRequest returned by the poll() of the WriteRequestQueue may return null if the queue is empty.

      In our case the destroy was invoked after polling a CLOSE_REQUEST caused by an earlier closeOnFlush(), and the write request queue was empty.

      AbstractIoSession.java
          protected void destroy() {
              if (writeRequestQueue != null) {
                  while (!writeRequestQueue.isEmpty(this)) {
                      WriteRequest writeRequest = writeRequestQueue.poll(this);
                      WriteFuture writeFuture = writeRequest.getFuture();
                      
                      // The WriteRequest may not always have a future : The CLOSE_REQUEST
                      // and MESSAGE_SENT_REQUEST don't.
                      if (writeFuture != null) {
                          writeFuture.setWritten();
                      }
                  }
              }
          }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              cwicklow Carl Wicklow
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: