[
https://issues.apache.org/jira/browse/DIRMINA-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13032358#comment-13032358
]
Borislav Parvanov commented on DIRMINA-832:
-------------------------------------------
In 2.0.4 ClassCastException is thrown when connect fails:
[13:57:17] NioSocketConnector-1 WARN [] []
[org.apache.mina.util.DefaultExceptionMonitor] - Unexpected exception.
java.lang.ClassCastException:
org.apache.mina.core.polling.AbstractPollingIoConnector$ConnectionRequest
cannot be cast to org.apache.mina.core.session.IoSession
at
org.apache.mina.transport.socket.nio.NioSocketConnector.close(NioSocketConnector.java:218)
at
org.apache.mina.transport.socket.nio.NioSocketConnector.close(NioSocketConnector.java:48)
at
org.apache.mina.core.polling.AbstractPollingIoConnector.cancelKeys(AbstractPollingIoConnector.java:404)
at
org.apache.mina.core.polling.AbstractPollingIoConnector.access$900(AbstractPollingIoConnector.java:64)
at
org.apache.mina.core.polling.AbstractPollingIoConnector$Connector.run(AbstractPollingIoConnector.java:513)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
> NullPointerException logged by ExceptionMonitor while invoking a
> NioSocketConnector.connect() that fails
> --------------------------------------------------------------------------------------------------------
>
> Key: DIRMINA-832
> URL: https://issues.apache.org/jira/browse/DIRMINA-832
> Project: MINA
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0.3
> Reporter: Matteo Candaten
> Fix For: 2.0.4
>
>
> A NullPointerException is logged by the ExceptionMonitor while invoking
> NioSocketConnector.connect(SocketAddress remoteAddress).
> This occurs in a failure scenario where the connect fails (the connectFuture
> eventually returns a "java.net.ConnectException: Connection refused"
> exception).
> This is the stack trace:
> WARN 27Apr 19:01:33.761 [thread-0] DefaultExceptionMonitor Unexpected
> exception.
> java.lang.NullPointerException
> at
> org.apache.mina.transport.socket.nio.NioSocketConnector.close(NioSocketConnector.java:218)
> at
> org.apache.mina.transport.socket.nio.NioSocketConnector.close(NioSocketConnector.java:48)
> at
> org.apache.mina.core.polling.AbstractPollingIoConnector.connect0(AbstractPollingIoConnector.java:335)
> at
> org.apache.mina.core.service.AbstractIoConnector.connect(AbstractIoConnector.java:262)
> at
> org.apache.mina.core.service.AbstractIoConnector.connect(AbstractIoConnector.java:172)
> the AbstractPollingIoConnector invokes the close(handle) method following the
> connection failure, and the implementation of that method in
> NioSocketConnector throws a NullPointerException on line 218:
> 210 @Override
> 211 protected void close(SocketChannel handle) throws Exception {
> 212 SelectionKey key = handle.keyFor(selector);
> 213
> 214 if (key != null) {
> 215 key.cancel();
> 216 }
> 217
> 218 IoSession session = (IoSession)key.attach(null);
> 219 IoFilterChain filterChain = session.getFilterChain();
> 220 filterChain.fireSessionClosed();
> 221
> 222 handle.close();
> 223 }
> I think lines 218-220 were added in version 2.0.3. I suspect the fix is to
> move them inside the if (key != null) { } block above.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira