[
https://issues.apache.org/jira/browse/SSHD-458?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Goldstein Lyor updated SSHD-458:
--------------------------------
Priority: Minor (was: Major)
> Make list of managed sessions consistent in a SessionListener
> -------------------------------------------------------------
>
> Key: SSHD-458
> URL: https://issues.apache.org/jira/browse/SSHD-458
> Project: MINA SSHD
> Issue Type: Bug
> Affects Versions: 0.14.0
> Reporter: Clement Pellerin
> Priority: Minor
>
> The list of managed sessions obtained from the sessionCreated() method of a
> SessionListener depends on the IO Service.
> When running the MinaService, the list of managed sessions already contains
> the newly created session that triggered the SessionListener. The first call
> will return size==1.
> When running the Nio2Service, the list of managed sessions does not contain
> the newly created session. The first call will return size==0.
> It would be preferable if the behavior was the same. This would make it
> easier to implement algorithms that depend on the size of the list without
> special knowledge about the running IO Service.
> 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) {
> int size =
> session.getIoSession().getService().getManagedSessions().size();
> }
> 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);
> // to run with MinaService
> server.setIoServiceFactoryFactory(new MinaServiceFactoryFactory());
> // to run with Nio2Service
> //server.setIoServiceFactoryFactory(new Nio2ServiceFactoryFactory());
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)