You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Matthew Phillips (JIRA)" <ji...@apache.org> on 2007/12/04 01:04:43 UTC

[jira] Commented: (DIRMINA-435) NullPointerException in IoServiceListenerSupport

    [ https://issues.apache.org/jira/browse/DIRMINA-435?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12548063 ] 

Matthew Phillips commented on DIRMINA-435:
------------------------------------------

This problem just bit me again, so I embarked on on some tracing. It happens on WinXP when trying to connect to an overseas host, so it may be triggered by the extra latency (the same code works fine for most other cases).

What seems to be causing it is MINA's SocketConnector class assuming that SocketChannel.finishConnect () will always return true, i.e. return when the connection is established. This is false in my case, resulting in a null remote address (SocketChannel.socket().getRemoteSocketAddress(), see line 334), which triggers the NPE in the worker.

Using the changes in the  patch I'll attach shortly fixes this and established a connection successfully. These changes effectively poll finishConnect() for up to 10 seconds, throwing an exception if it ultimately failed.


> NullPointerException in IoServiceListenerSupport
> ------------------------------------------------
>
>                 Key: DIRMINA-435
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-435
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.1.2
>         Environment: WinXP SP 2
> java version "1.5.0_11"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)
>            Reporter: Matthew Phillips
>
> This is an odd one, since it occurs on WinXP and not on Mac OS X. The error was seen under 1.5, but also occurs on 1.6. I see the following NPE :
> -----
> Exception trace:
> java.lang.NullPointerException
> 	at java.util.concurrent.ConcurrentHashMap.hash(Unknown Source)
> 	at java.util.concurrent.ConcurrentHashMap.putIfAbsent(Unknown Source)
> 	at org.apache.mina.common.support.IoServiceListenerSupport.fireSessionCreated(IoServiceListenerSupport.java:152)
> 	at org.apache.mina.transport.socket.nio.SocketIoProcessor.doAddNew(SocketIoProcessor.java:135)
> 	at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$300(SocketIoProcessor.java:44)
> 	at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:444)
> 	at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:39)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> 	at java.lang.Thread.run(Unknown Source)
> ------
> The NPE is being caused by IoSession.getServiceAddress () returning null, which then bombs the attempt to use it as a key in the map (IoServiceListenerSupport:151):
>        SocketAddress serviceAddress = session.getServiceAddress(); // null
>         // Get the session set.
>         Set<IoSession> s = new IdentityHashSet<IoSession>();
>         Set<IoSession> sessions = managedSessions.putIfAbsent(serviceAddress,
>                 Collections.synchronizedSet(s));
> This has me stumped. Can anyone help?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.