[
https://issues.apache.org/jira/browse/SSHD-931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16896780#comment-16896780
]
Goldstein Lyor commented on SSHD-931:
-------------------------------------
Indeed there is a problem here since the {{SftpSubsystem}} is using the
executor service provided to it by the factory - and if that one is wrapped
inside a {{NoCloseExecutor}} then after the 1st SFTP session it will be marked
as being shut down and thus not allow another connection. There is however a
workaround for this (until we fix the issue more thoroughly) - extend
{{SftpSubsystemFactory}} and override its {{getExecutorService}} to provide a
*new* {{NoCloseExecutor}} every time it is invoked:
{code:java}
public class MySftpSubsystemFactory extends SftpSubsystemFactory {
@Override
public CloseableExecutorService getExecutorService() {
return ThreadUtils.noClose(super.getExecutorService());
}
}
SshServer server = ...setup server..
server.setSubsystemFactories(Collections.singletonList(new
MySftpSubsystemFactory()));
{code}
> SftpSubsystem.destroy() will terminate external FixedThreadPool
> ExecutorService - preventing re-connects
> --------------------------------------------------------------------------------------------------------
>
> Key: SSHD-931
> URL: https://issues.apache.org/jira/browse/SSHD-931
> Project: MINA SSHD
> Issue Type: Bug
> Affects Versions: 2.2.0
> Environment: Linux RH
> Reporter: Alla Gofman
> Assignee: Goldstein Lyor
> Priority: Major
>
> Similar bug from the 1.2.0 version
> https://issues.apache.org/jira/browse/SSHD-669
>
> In SftpSubsystem on performing the destroy logic (on a client disconnect
> f.e.), the code will also terminate the current executor service as well.
> [https://github.com/apache/mina-sshd/blob/master/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java#L1001]
> *** There is no shutdownExecutor parameter in SftpSubsystem.
>
> 2019-07-14 19:00:14,236 ERROR [sshd-FactoryExecutorService-thread-1]
> (SftpSubsystem:316) -
> run(ServerSessionImpl[user1@DOMAIN/137.72.216.21:50597]) InterruptedException
> caught in SFTP subsystem: null
> 2019-07-14 19:00:14,236 DEBUG [sshd-FactoryExecutorService-thread-1]
> (SftpSubsystem:319) -
> run(ServerSessionImpl[[email protected]/137.72.216.21:50597])
> caught exception details
> java.lang.InterruptedException: null
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2056)
> ~[?:?]
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2090)
> ~[?:?]
> at
> java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:433)
> ~[?:?]
> at
> org.apache.sshd.server.subsystem.sftp.SftpSubsystem.run(SftpSubsystem.java:304)
> [sshd-sftp-2.2.0.jar!/:2.2.0]
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
> [?:?]
> at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> [?:?]
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> [?:?]
> at java.lang.Thread.run(Thread.java:834) [?:?]
> ----------------------------------------------------------------------------------------------------------------------
> Using protectExecutorServiceShutdown wrapper with shutdownOnExit = false will
> not solve the problem due to another exception thrown from NoCloseExecutor by
> ValidateUtils.checkState(!isShutdown(), "Executor has been shut down");
> ***The second time !isShutdown() issues it will return true!!!
> [https://github.com/apache/mina-sshd/blob/master/sshd-common/src/main/java/org/apache/sshd/common/util/threads/NoCloseExecutor.java#L66]
> 2019-07-12 22:18:07,097 ERROR
> [sshd-SshServer[3245efdb](port=1222)-nio2-thread-8]
> (HubSftpSubsystemWrapper:274) - Failed (IllegalStateException) to start
> command: java.lang.IllegalStateException: Executor has been shut down
> java.lang.IllegalStateException: Executor has been shut down
> at
> org.apache.sshd.common.util.ValidateUtils.createFormattedException(ValidateUtils.java:213)
> ~[sshd-common-2.2.0.jar!/:2.2.0]
> at
> org.apache.sshd.common.util.ValidateUtils.throwIllegalStateException(ValidateUtils.java:207)
> ~[sshd-common-2.2.0.jar!/:2.2.0]
> at
> org.apache.sshd.common.util.ValidateUtils.checkState(ValidateUtils.java:184)
> ~[sshd-common-2.2.0.jar!/:2.2.0]
> at
> org.apache.sshd.common.util.threads.NoCloseExecutor.submit(NoCloseExecutor.java:66)
> ~[sshd-common-2.2.0.jar!/:2.2.0]
>
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]