I sorted out the problem. Which took quite awhile...but I'll get to that later. The problem was that in:

org.apache.mina.example.proxy.AbstractProxyIoHandler:

public void sessionClosed( IoSession session ) throws Exception
   {
       if( session.getAttachment() != null )
       {
           ( ( IoSession ) session.getAttachment() ).setAttachment( null );
           ( ( IoSession ) session.getAttachment() ).close();
           session.setAttachment( null );
       }
   }

The call to session.setAttachemnt(null) throws an NullPointerException.

In Mina 1.0 the backing Map for Attributes/Attachements is a HashMap. In 1.1 it is a ConcurrentHashMap. ConcurrentHashMap throws a NPE when one tries to put a null value into the map. HashMaps do not.

There are a few ways to fix this...not sure what the mina folks want to do:

- special case nulls in setAttaachement()
- add a removeAttachement() call, like removeAttribute()
- change the backing map

This was hard to find because the NPE was being eaten. I added logging filters to the app, but didn't do anything with the IO adapters. Once I implemented exceptionCaught() in AbstractProxyIoHandler, it was easy to find the problem. I think that the default action for exceptionCaught should be to report the error (in IoHandlerAdapter, and other places). Force people to turn it off once they have figured things out. It will make debugging a lot easier.

Keith

Keith McNeill wrote:
I'm trying to use mina to build a proxy. I'm working with the example proxy. I can get the example proxy (as distributed with no changes) to work on mina 1.0. But if I try it in mina 1.1 it doesn't work. The request from the client to the server is making it through the proxy to the server. The server responds and it appears that the response is being processed by the ServerToProxyIoHandler but that it doesn't make it back to the client. My client app hangs/waits for a response at this point.

Taking a look at the stack dump in this state the threads appear to be just waiting for work. I.e. they don't appear to be deadlocked anywhere.

If I put filters on that just log method calls. The first thing that goes amiss is that after the ServerToProxyIoHandler does a write:

- in 1.0 the filter quickly reports a call to close is made. - in 1.1 that close call is never made. As I'm new to mina, any suggestions on where to put some debugging effort?

Keith

Reply via email to