This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git


The following commit(s) were added to refs/heads/master by this push:
     new b00796a  [SSHD-1083] Relaxed required Nio2Connector/Acceptor required 
constructor arguments
b00796a is described below

commit b00796af384b00a7d723cc7b806c1bdbcbdb0a18
Author: Lyor Goldstein <lgoldst...@apache.org>
AuthorDate: Fri Apr 2 09:52:17 2021 +0300

    [SSHD-1083] Relaxed required Nio2Connector/Acceptor required constructor 
arguments
---
 CHANGES.md                                         |  1 +
 .../sshd/client/auth/pubkey/UserAuthPublicKey.java |  3 ++-
 .../apache/sshd/common/io/nio2/Nio2Acceptor.java   | 10 ++++-----
 .../apache/sshd/common/io/nio2/Nio2Connector.java  | 25 +++++++++++-----------
 .../apache/sshd/common/io/nio2/Nio2Service.java    | 20 ++++++-----------
 .../apache/sshd/common/io/nio2/Nio2Session.java    | 15 +++++++------
 .../DefaultClientKexExtensionHandler.java          |  4 ++--
 7 files changed, 37 insertions(+), 41 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 5a6ffd8..751f15b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -23,6 +23,7 @@
 
 * [SSHD-525](https://issues.apache.org/jira/browse/SSHD-525) Added support for 
SFTP **client-side** ["posix-ren...@openssh.com"
  
extension](http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL?rev=1.28&content-type=text/x-cvsweb-markup)
 - see section 3.3
+* [SSHD-1083](https://issues.apache.org/jira/browse/SSHD-1083) Relaxed 
required `Nio2Connector/Acceptor` required constructor arguments
 * [SSHD-1085](https://issues.apache.org/jira/browse/SSHD-1085) Added 
`CliLogger` + more verbosity on `SshClientMain`
 * [SSHD-1109](https://issues.apache.org/jira/browse/SSHD-1109) Route tests JUL 
logging via SLF4JBridgeHandler
 * [SSHD-1109](https://issues.apache.org/jira/browse/SSHD-1109) Provide full 
slf4j logger capabilities to CliLogger + use it in all CLI classes
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
 
b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
index 1326109..fb3561f 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
@@ -117,7 +117,8 @@ public class UserAuthPublicKey extends AbstractUserAuth 
implements SignatureFact
                     // with this key and other signature algorithms. Skip to 
the
                     // next key, if any.
                     if (log.isDebugEnabled()) {
-                        log.debug("sendAuthDataRequest({})[{}] server rejected 
publickey authentication with known signature algorithm {}",
+                        log.debug(
+                                "sendAuthDataRequest({})[{}] server rejected 
publickey authentication with known signature algorithm {}",
                                 session, service, chosenAlgorithm);
                     }
                     currentAlgorithm = null;
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java 
b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java
index 25915a0..428e69f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java
@@ -35,7 +35,7 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.sshd.common.Closeable;
-import org.apache.sshd.common.FactoryManager;
+import org.apache.sshd.common.PropertyResolver;
 import org.apache.sshd.common.io.IoAcceptor;
 import org.apache.sshd.common.io.IoHandler;
 import org.apache.sshd.common.io.IoServiceEventListener;
@@ -51,9 +51,9 @@ public class Nio2Acceptor extends Nio2Service implements 
IoAcceptor {
     protected final Map<SocketAddress, AsynchronousServerSocketChannel> 
channels = new ConcurrentHashMap<>();
     private int backlog;
 
-    public Nio2Acceptor(FactoryManager manager, IoHandler handler, 
AsynchronousChannelGroup group) {
-        super(manager, handler, group);
-        backlog = CoreModuleProperties.SOCKET_BACKLOG.getRequired(manager);
+    public Nio2Acceptor(PropertyResolver propertyResolver, IoHandler handler, 
AsynchronousChannelGroup group) {
+        super(propertyResolver, handler, group);
+        backlog = 
CoreModuleProperties.SOCKET_BACKLOG.getRequired(propertyResolver);
     }
 
     @Override
@@ -352,7 +352,7 @@ public class Nio2Acceptor extends Nio2Service implements 
IoAcceptor {
             if (log.isTraceEnabled()) {
                 log.trace("createNio2Session({}) address={}", acceptor, 
address);
             }
-            return new Nio2Session(acceptor, getFactoryManager(), handler, 
channel, address);
+            return new Nio2Session(acceptor, propertyResolver, handler, 
channel, address);
         }
 
         @Override
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Connector.java 
b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Connector.java
index 7055e51..b12e37d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Connector.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Connector.java
@@ -24,7 +24,7 @@ import java.nio.channels.AsynchronousChannelGroup;
 import java.nio.channels.AsynchronousSocketChannel;
 
 import org.apache.sshd.common.AttributeRepository;
-import org.apache.sshd.common.FactoryManager;
+import org.apache.sshd.common.PropertyResolver;
 import org.apache.sshd.common.future.DefaultSshFuture;
 import org.apache.sshd.common.io.IoConnectFuture;
 import org.apache.sshd.common.io.IoConnector;
@@ -40,8 +40,8 @@ import org.apache.sshd.common.util.ValidateUtils;
  * @author <a href="mailto:d...@mina.apache.org";>Apache MINA SSHD Project</a>
  */
 public class Nio2Connector extends Nio2Service implements IoConnector {
-    public Nio2Connector(FactoryManager manager, IoHandler handler, 
AsynchronousChannelGroup group) {
-        super(manager, handler, group);
+    public Nio2Connector(PropertyResolver propertyResolver, IoHandler handler, 
AsynchronousChannelGroup group) {
+        super(propertyResolver, handler, group);
     }
 
     @Override
@@ -64,7 +64,7 @@ public class Nio2Connector extends Nio2Service implements 
IoConnector {
             }
             Nio2CompletionHandler<Void, Object> completionHandler = 
ValidateUtils.checkNotNull(
                     createConnectionCompletionHandler(
-                            future, socket, context, getFactoryManager(), 
getIoHandler()),
+                            future, socket, context, propertyResolver, 
getIoHandler()),
                     "No connection completion handler created for %s",
                     address);
             socket.connect(address, null, completionHandler);
@@ -109,24 +109,25 @@ public class Nio2Connector extends Nio2Service implements 
IoConnector {
 
     protected Nio2CompletionHandler<Void, Object> 
createConnectionCompletionHandler(
             IoConnectFuture future, AsynchronousSocketChannel socket,
-            AttributeRepository context, FactoryManager manager, IoHandler 
handler) {
-        return new ConnectionCompletionHandler(future, socket, context, 
manager, handler);
+            AttributeRepository context, PropertyResolver propertyResolver, 
IoHandler handler) {
+        return new ConnectionCompletionHandler(future, socket, context, 
propertyResolver, handler);
     }
 
     protected class ConnectionCompletionHandler extends 
Nio2CompletionHandler<Void, Object> {
         protected final IoConnectFuture future;
         protected final AsynchronousSocketChannel socket;
         protected final AttributeRepository context;
-        protected final FactoryManager manager;
+        protected final PropertyResolver propertyResolver;
         protected final IoHandler handler;
 
         protected ConnectionCompletionHandler(
                                               IoConnectFuture future, 
AsynchronousSocketChannel socket,
-                                              AttributeRepository context, 
FactoryManager manager, IoHandler handler) {
+                                              AttributeRepository context, 
PropertyResolver propertyResolver,
+                                              IoHandler handler) {
             this.future = future;
             this.socket = socket;
             this.context = context;
-            this.manager = manager;
+            this.propertyResolver = propertyResolver;
             this.handler = handler;
         }
 
@@ -142,7 +143,7 @@ public class Nio2Connector extends Nio2Service implements 
IoConnector {
                     listener.connectionEstablished(Nio2Connector.this, local, 
context, remote);
                 }
 
-                Nio2Session session = createSession(manager, handler, socket);
+                Nio2Session session = createSession(propertyResolver, handler, 
socket);
                 if (context != null) {
                     session.setAttribute(AttributeRepository.class, context);
                 }
@@ -200,9 +201,9 @@ public class Nio2Connector extends Nio2Service implements 
IoConnector {
     }
 
     protected Nio2Session createSession(
-            FactoryManager manager, IoHandler handler, 
AsynchronousSocketChannel socket)
+            PropertyResolver propertyResolver, IoHandler handler, 
AsynchronousSocketChannel socket)
             throws Throwable {
-        return new Nio2Session(this, manager, handler, socket, null);
+        return new Nio2Session(this, propertyResolver, handler, socket, null);
     }
 
     public static class DefaultIoConnectFuture extends 
DefaultSshFuture<IoConnectFuture> implements IoConnectFuture {
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java 
b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
index af79a8d..85acb77 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
@@ -35,8 +35,6 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.sshd.common.Closeable;
-import org.apache.sshd.common.FactoryManager;
-import org.apache.sshd.common.FactoryManagerHolder;
 import org.apache.sshd.common.Property;
 import org.apache.sshd.common.PropertyResolver;
 import org.apache.sshd.common.io.IoHandler;
@@ -50,7 +48,7 @@ import org.apache.sshd.core.CoreModuleProperties;
 /**
  * @author <a href="mailto:d...@mina.apache.org";>Apache MINA SSHD Project</a>
  */
-public abstract class Nio2Service extends AbstractInnerCloseable implements 
IoService, FactoryManagerHolder {
+public abstract class Nio2Service extends AbstractInnerCloseable implements 
IoService {
     // Note: order may be important so that's why we use a LinkedHashMap
     public static final Map<Property<?>, SimpleImmutableEntry<SocketOption<?>, 
Object>> CONFIGURABLE_OPTIONS;
 
@@ -68,16 +66,16 @@ public abstract class Nio2Service extends 
AbstractInnerCloseable implements IoSe
 
     protected final Map<Long, IoSession> sessions;
     protected final AtomicBoolean disposing = new AtomicBoolean();
-    private final FactoryManager manager;
+    protected final PropertyResolver propertyResolver;
     private final IoHandler handler;
     private final AsynchronousChannelGroup group;
     private IoServiceEventListener eventListener;
 
-    protected Nio2Service(FactoryManager manager, IoHandler handler, 
AsynchronousChannelGroup group) {
+    protected Nio2Service(PropertyResolver propertyResolver, IoHandler 
handler, AsynchronousChannelGroup group) {
         if (log.isTraceEnabled()) {
             log.trace("Creating {}", getClass().getSimpleName());
         }
-        this.manager = Objects.requireNonNull(manager, "No factory manager 
provided");
+        this.propertyResolver = Objects.requireNonNull(propertyResolver, "No 
property resolver provided");
         this.handler = Objects.requireNonNull(handler, "No I/O handler 
provided");
         this.group = Objects.requireNonNull(group, "No async. channel group 
provided");
         this.sessions = new ConcurrentHashMap<>();
@@ -97,11 +95,6 @@ public abstract class Nio2Service extends 
AbstractInnerCloseable implements IoSe
         return group;
     }
 
-    @Override
-    public FactoryManager getFactoryManager() {
-        return manager;
-    }
-
     public IoHandler getIoHandler() {
         return handler;
     }
@@ -112,7 +105,7 @@ public abstract class Nio2Service extends 
AbstractInnerCloseable implements IoSe
                 log.warn("dispose({}) already disposing", this);
             }
 
-            Duration maxWait = 
Closeable.getMaxCloseWaitTime(getFactoryManager());
+            Duration maxWait = Closeable.getMaxCloseWaitTime(propertyResolver);
             boolean successful = close(true).await(maxWait);
             if (!successful) {
                 throw new SocketTimeoutException("Failed to receive closure 
confirmation within " + maxWait);
@@ -169,8 +162,7 @@ public abstract class Nio2Service extends 
AbstractInnerCloseable implements IoSe
     protected <T> boolean setOption(
             NetworkChannel socket, Property<?> property, SocketOption<T> 
option, T defaultValue)
             throws IOException {
-        PropertyResolver manager = getFactoryManager();
-        String valStr = manager.getString(property.getName());
+        String valStr = propertyResolver.getString(property.getName());
         T val = defaultValue;
         if (!GenericUtils.isEmpty(valStr)) {
             Class<T> type = option.type();
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java 
b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
index 66474ea..1bf616a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
@@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.apache.sshd.common.FactoryManager;
+import org.apache.sshd.common.PropertyResolver;
 import org.apache.sshd.common.RuntimeSshException;
 import org.apache.sshd.common.future.CloseFuture;
 import org.apache.sshd.common.io.IoHandler;
@@ -63,7 +63,7 @@ public class Nio2Session extends AbstractCloseable implements 
IoSession {
     private final SocketAddress localAddress;
     private final SocketAddress remoteAddress;
     private final SocketAddress acceptanceAddress;
-    private final FactoryManager manager;
+    private final PropertyResolver propertyResolver;
     private final Queue<Nio2DefaultIoWriteFuture> writes = new 
LinkedTransferQueue<>();
     private final AtomicReference<Nio2DefaultIoWriteFuture> currentWrite = new 
AtomicReference<>();
     private final AtomicLong readCyclesCounter = new AtomicLong();
@@ -75,11 +75,12 @@ public class Nio2Session extends AbstractCloseable 
implements IoSession {
     private volatile Runnable readRunnable;
 
     public Nio2Session(
-                       Nio2Service service, FactoryManager manager, IoHandler 
handler, AsynchronousSocketChannel socket,
+                       Nio2Service service, PropertyResolver propertyResolver, 
IoHandler handler,
+                       AsynchronousSocketChannel socket,
                        SocketAddress acceptanceAddress)
                                                         throws IOException {
         this.service = Objects.requireNonNull(service, "No service instance");
-        this.manager = Objects.requireNonNull(manager, "No factory manager");
+        this.propertyResolver = Objects.requireNonNull(propertyResolver, "No 
property resolver");
         this.ioHandler = Objects.requireNonNull(handler, "No IoHandler");
         this.socketChannel = Objects.requireNonNull(socket, "No socket 
channel");
         this.localAddress = socket.getLocalAddress();
@@ -301,7 +302,7 @@ public class Nio2Session extends AbstractCloseable 
implements IoSession {
     }
 
     public void startReading() {
-        
startReading(CoreModuleProperties.NIO2_READ_BUFFER_SIZE.getRequired(manager));
+        
startReading(CoreModuleProperties.NIO2_READ_BUFFER_SIZE.getRequired(propertyResolver));
     }
 
     public void startReading(int bufSize) {
@@ -423,7 +424,7 @@ public class Nio2Session extends AbstractCloseable 
implements IoSession {
         }
 
         AsynchronousSocketChannel socket = getSocket();
-        Duration readTimeout = 
CoreModuleProperties.NIO2_READ_TIMEOUT.getRequired(manager);
+        Duration readTimeout = 
CoreModuleProperties.NIO2_READ_TIMEOUT.getRequired(propertyResolver);
         readCyclesCounter.incrementAndGet();
         lastReadCycleStart.set(System.nanoTime());
         socket.read(buffer, readTimeout.toMillis(), TimeUnit.MILLISECONDS, 
null, completion);
@@ -459,7 +460,7 @@ public class Nio2Session extends AbstractCloseable 
implements IoSession {
 
     protected void doWriteCycle(ByteBuffer buffer, 
Nio2CompletionHandler<Integer, Object> completion) {
         AsynchronousSocketChannel socket = getSocket();
-        Duration writeTimeout = 
CoreModuleProperties.NIO2_MIN_WRITE_TIMEOUT.getRequired(manager);
+        Duration writeTimeout = 
CoreModuleProperties.NIO2_MIN_WRITE_TIMEOUT.getRequired(propertyResolver);
         writeCyclesCounter.incrementAndGet();
         lastWriteCycleStart.set(System.nanoTime());
         socket.write(buffer, writeTimeout.toMillis(), TimeUnit.MILLISECONDS, 
null, completion);
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/kex/extension/DefaultClientKexExtensionHandler.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/kex/extension/DefaultClientKexExtensionHandler.java
index e1f24e0..19a0324 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/kex/extension/DefaultClientKexExtensionHandler.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/kex/extension/DefaultClientKexExtensionHandler.java
@@ -115,8 +115,8 @@ public class DefaultClientKexExtensionHandler extends 
AbstractLoggingBean implem
     }
 
     /**
-     * Perform updates after a server-sig-algs extension has been received. 
The set of algorithms
-     * announced by the server is set as attribute {@link #SERVER_ALGORITHMS} 
of the {@code session}.
+     * Perform updates after a server-sig-algs extension has been received. 
The set of algorithms announced by the
+     * server is set as attribute {@link #SERVER_ALGORITHMS} of the {@code 
session}.
      *
      * @param session          the message was received for
      * @param serverAlgorithms signature algorithm names announced by the 
server

Reply via email to