Carl Wicklow created DIRMINA-1047:
-------------------------------------

             Summary: NullPointerException in AbstractIOSession.destroy()
                 Key: DIRMINA-1047
                 URL: https://issues.apache.org/jira/browse/DIRMINA-1047
             Project: MINA
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.0.14
         Environment: Any
            Reporter: Carl Wicklow



After upgrading to 2.0.14, we get this NPE ...

{noformat}
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)
{noformat}

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.

{code:title=AbstractIoSession.java|borderStyle=solid}
    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();
                }
            }
        }
    }
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to