Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.1.0
-
None
-
Important
Description
The current code uses ServiceLoader#load mechanism to detect any 3rd party provided IoServiceFactoryFactory-ies. However, since Nio2ServiceFactoryFactory is always present in the sshd-core, it is always picked up along with any others that the user may have placed in the classpath. Furthermore, the service loading mechanism makes no guarantees as to the order in which registered services are scanned. Since the mechanism that instantiates the factory uses the "first" detected factory it is pretty much useless - unless the user configures the org.apache.sshd.common.io.IoServiceFactoryFactory system property.
The correct flow should be:
- Consult org.apache.sshd.common.io.IoServiceFactoryFactory system property
- If no specific factory specified - scan the service loaders
- If exactly one found then use it - fail if multiple ones registered
- Otherwise use Nio2ServiceFactoryFactory