On Tue, Oct 21, 2008 at 1:50 PM, Mezei Zoltan <[EMAIL PROTECTED]> wrote:
> On Tue, Oct 21, 2008 at 1:45 PM, Emmanuel Lecharny <[EMAIL PROTECTED]> wrote:
>> I would like to know if the trunk with this patch :
>>
>> http://svn.apache.org/viewvc?rev=706585&view=rev
>>
>> fixes the problem. Anywone can test it ?
>
> I'll do it now, however it might take a time to get mina compiled from
> source, I didn't do that before.

Ok, I did it, but it didn't help :-(

I used the following test class:


package test;

import java.net.InetSocketAddress;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.mina.core.future.ConnectFuture;
import org.apache.mina.core.service.IoConnector;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.filter.logging.LoggingFilter;
import org.apache.mina.transport.socket.nio.NioSocketConnector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TestServletContextListener implements ServletContextListener {

    public void contextInitialized(ServletContextEvent arg0) {
        Logger logger = LoggerFactory.getLogger("test");
        IoConnector ioConnector = new NioSocketConnector();
        ioConnector.getFilterChain().addLast("logger", new LoggingFilter());
        ioConnector.setHandler(new IoHandlerAdapter());
        logger.debug("Before connect...");
        ConnectFuture cf = ioConnector.connect(new
InetSocketAddress("localhost", 19971));
        logger.debug("After connect...");
        logger.debug("Before await...");
        cf.awaitUninterruptibly();
        logger.debug("After await...");
    }

    public void contextDestroyed(ServletContextEvent arg0) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}


It was used in a .war file with the following web.xml:


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";>
    <listener>
        <description>ServletContextListener</description>
        <listener-class>test.TestServletContextListener</listener-class>
    </listener>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
</web-app>


When I deployed the war file to a glassfish instance it yielded the
following logs:


14:55:55.469 [pool-1-thread-4] DEBUG test - Before connect...
14:55:55.484 [pool-1-thread-4] DEBUG test - After connect...
14:55:55.484 [pool-1-thread-4] DEBUG test - Before await...
14:55:56.422 [NioSocketConnector-1] WARN
o.a.m.util.DefaultExceptionMonitor - Unexpected exception.
java.lang.NullPointerException
        at 
java.util.concurrent.ConcurrentLinkedQueue.offer(ConcurrentLinkedQueue.java:190)
        at 
org.apache.mina.core.polling.AbstractPollingIoConnector.processConnections(AbstractPollingIoConnector.java:440)
        at 
org.apache.mina.core.polling.AbstractPollingIoConnector.access$500(AbstractPollingIoConnector.java:64)
        at 
org.apache.mina.core.polling.AbstractPollingIoConnector$Connector.run(AbstractPollingIoConnector.java:476)
        at 
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:65)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)


I used the current trunk version of MINA with your patch.

>From the log I guess that in AbstractPollingIoConnector the following
line fails:

            } finally {
                if (!success) {
                    // The connection failed, we have to cancel it.
                    cancelQueue.offer(connectionRequest);  // <-----
This line fails with NPE
                }
            }

It might mean that it is possible that in some situations the
cancelQueue might not have been initialized before the offer statement
but that's not the case here. But according to the javadoc:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html#offer(E)

offer() might throw an NPE when the offered element (connectionRequest
in this case) is null.

Now, I don't know why/how that can happen :-(
-- 
Zizi

"Oh, by the way... Anyone still experiencing stress by the end of the
day... WILL BE FIRED!!!"

Reply via email to