Clement Pellerin created SSHD-456:
-------------------------------------
Summary: Nio2Acceptor does not unmanage the session upon exception
in SessionListener
Key: SSHD-456
URL: https://issues.apache.org/jira/browse/SSHD-456
Project: MINA SSHD
Issue Type: Bug
Affects Versions: 0.14.0
Reporter: Clement Pellerin
When the sessionCreated() method of a SessionListener throws an exception the
Nio2Acceptor gets confused. The IoService stops listening for new connections
(socket.accept() is not called again) and the rejected session is never
unmanaged.
The bug occurs in the exception handling of
Nio2Acceptor.AcceptCompletionHandler.onCompleted()
{code}
try {
// Create a session
Nio2Session session = new Nio2Session(Nio2Acceptor.this,
handler, result);
handler.sessionCreated(session);
sessions.put(session.getId(), session);
session.startReading();
// Accept new connections
socket.accept(address, this);
} catch (Throwable exc) {
failed(exc, address);
}
{code}
Here is a sample SessionListener
{code}
import org.apache.sshd.common.Session;
import org.apache.sshd.common.SessionListener;
public class MySessionListener implements SessionListener
{
public void sessionCreated(Session session) {
throw new RuntimeException();
}
public void sessionEvent(Session session, Event event) {
}
public void sessionClosed(Session session) {
}
}
{code}
Here is how to attach the SessionListener:
{code}
SshServer server = ...;
SessionFactory sessionFactory = new SessionFactory();
sessionFactory.addListener(new MySessionListener());
server.setSessionFactory(sessionFactory);
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)