From 73883a5c266ee6029ca49e19d18c08516b61aa38 Mon Sep 17 00:00:00 2001
From: Lyor Goldstein
@@ -110,7 +111,7 @@ public boolean hasNext() { nextPassword.set(password); } - return !GenericUtils.isSameReference(password, EOF); + return !UnaryEquator.isSameReference(password, EOF); } @Override @@ -120,7 +121,7 @@ public String next() { throw new IllegalStateException("hasNext() not called before next()"); } - if (GenericUtils.isSameReference(password, EOF)) { + if (UnaryEquator.isSameReference(password, EOF)) { throw new NoSuchElementException("All passwords exhausted"); } diff --git a/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/compression/DeflatingInputStream.java b/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/compression/DeflatingInputStream.java index 9f80d2324..ff4cd5e5d 100644 --- a/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/compression/DeflatingInputStream.java +++ b/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/compression/DeflatingInputStream.java @@ -25,7 +25,7 @@ import java.io.StreamCorruptedException; import java.util.Objects; -import org.apache.sshd.common.util.GenericUtils; +import org.apache.sshd.common.util.ExceptionUtils; import org.apache.sshd.common.util.io.IoUtils; import org.apache.sshd.contrib.common.util.io.ExposedBufferByteArrayOutputStream; @@ -159,25 +159,25 @@ public void close() throws IOException { try { compressor.close(); } catch (IOException e) { - err = GenericUtils.accumulateException(err, e); + err = ExceptionUtils.accumulateException(err, e); } try { baos.close(); } catch (IOException e) { - err = GenericUtils.accumulateException(err, e); + err = ExceptionUtils.accumulateException(err, e); } try { inputStream.close(); } catch (IOException e) { - err = GenericUtils.accumulateException(err, e); + err = ExceptionUtils.accumulateException(err, e); } try { super.close(); } catch (IOException e) { - err = GenericUtils.accumulateException(err, e); + err = ExceptionUtils.accumulateException(err, e); } if (err != null) { diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java index 60bf0bd2d..a91b1a271 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java @@ -33,7 +33,7 @@ import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.channel.ChannelOutputStream; import org.apache.sshd.common.session.Session; -import org.apache.sshd.common.util.GenericUtils; +import org.apache.sshd.common.util.ExceptionUtils; import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.buffer.Buffer; import org.apache.sshd.common.util.buffer.ByteArrayBuffer; @@ -69,7 +69,7 @@ protected OpenFuture doInit(Buffer buffer) { signalChannelOpenSuccess(); f.setOpened(); } catch (Throwable t) { - Throwable e = GenericUtils.peelException(t); + Throwable e = ExceptionUtils.peelException(t); changeEvent = e.getClass().getSimpleName(); signalChannelOpenFailure(e); f.setException(e); diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java index bbafa7b43..181ae864b 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java @@ -30,6 +30,7 @@ import org.apache.sshd.common.Closeable; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.channel.ChannelOutputStream; +import org.apache.sshd.common.util.ExceptionUtils; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.buffer.Buffer; @@ -100,7 +101,7 @@ protected OpenFuture doInit(Buffer buffer) { signalChannelOpenSuccess(); f.setOpened(); } catch (Throwable t) { - Throwable e = GenericUtils.peelException(t); + Throwable e = ExceptionUtils.peelException(t); signalChannelOpenFailure(e); f.setException(e); } diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java index e4cde28a8..d5fa90605 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java @@ -87,8 +87,10 @@ import org.apache.sshd.common.keyprovider.KeyIdentityProvider; import org.apache.sshd.common.keyprovider.KeyPairProvider; import org.apache.sshd.common.session.helpers.AbstractSession; +import org.apache.sshd.common.util.ExceptionUtils; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.ValidateUtils; +import org.apache.sshd.common.util.functors.UnaryEquator; import org.apache.sshd.common.util.io.resource.PathResource; import org.apache.sshd.common.util.net.SshdSocketAddress; import org.apache.sshd.core.CoreModuleProperties; @@ -755,7 +757,7 @@ protected void setupDefaultSessionIdentities( // check if session listener intervened KeyIdentityProvider kpSession = session.getKeyIdentityProvider(); KeyIdentityProvider kpClient = getKeyIdentityProvider(); - if (GenericUtils.isSameReference(kpSession, kpClient)) { + if (UnaryEquator.isSameReference(kpSession, kpClient)) { if (debugEnabled) { log.debug("setupDefaultSessionIdentities({}) key identity provider override in session listener", session); } @@ -763,7 +765,7 @@ protected void setupDefaultSessionIdentities( // Prefer the extra identities to come first since they were probably indicate by the host-config entry KeyIdentityProvider kpEffective = KeyIdentityProvider.resolveKeyIdentityProvider(extraIdentities, kpSession); - if (!GenericUtils.isSameReference(kpSession, kpEffective)) { + if (!UnaryEquator.isSameReference(kpSession, kpEffective)) { if (debugEnabled) { log.debug("setupDefaultSessionIdentities({}) key identity provider enhanced", session); } @@ -772,7 +774,7 @@ protected void setupDefaultSessionIdentities( PasswordIdentityProvider passSession = session.getPasswordIdentityProvider(); PasswordIdentityProvider passClient = getPasswordIdentityProvider(); - if (!GenericUtils.isSameReference(passSession, passClient)) { + if (!UnaryEquator.isSameReference(passSession, passClient)) { if (debugEnabled) { log.debug("setupDefaultSessionIdentities({}) password provider override", session); } @@ -853,13 +855,13 @@ public void close() throws IOException { try { client.close(); } catch (Exception e) { - err = GenericUtils.accumulateException(err, e); + err = ExceptionUtils.accumulateException(err, e); } try { client.stop(); } catch (Exception e) { - err = GenericUtils.accumulateException(err, e); + err = ExceptionUtils.accumulateException(err, e); } if (err != null) { diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java index c82c404b0..d960388ce 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java @@ -49,7 +49,7 @@ import org.apache.sshd.common.io.IoOutputStream; import org.apache.sshd.common.session.Session; import org.apache.sshd.common.util.EventNotifier; -import org.apache.sshd.common.util.GenericUtils; +import org.apache.sshd.common.util.ExceptionUtils; import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.buffer.Buffer; import org.apache.sshd.common.util.buffer.ByteArrayBuffer; @@ -359,7 +359,7 @@ public void handleOpenSuccess(int recipient, long rwSize, long packetSize, Buffe this.opened.set(true); this.openFuture.setOpened(); } catch (Throwable t) { - Throwable e = GenericUtils.peelException(t); + Throwable e = ExceptionUtils.peelException(t); changeEvent = e.getClass().getName(); signalChannelOpenFailure(e); this.openFuture.setException(e); diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java index 4a70dc467..88f8f03ca 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java @@ -31,6 +31,7 @@ import org.apache.sshd.common.channel.PtyMode; import org.apache.sshd.common.session.Session; import org.apache.sshd.common.util.GenericUtils; +import org.apache.sshd.common.util.MapEntryUtils; import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.buffer.Buffer; import org.apache.sshd.common.util.buffer.ByteArrayBuffer; @@ -45,7 +46,7 @@ *
* A typical code snippet would be: *
- * + * *
*
* try (client = SshClient.setUpDefaultClient()) {
@@ -93,7 +94,7 @@ public PtyCapableChannelSession(
this.config = PtyChannelConfigurationMutator.copyConfiguration(
configHolder, new PtyChannelConfiguration());
this.config.setPtyType(resolvePtyType(this.config));
- if (GenericUtils.isNotEmpty(env)) {
+ if (MapEntryUtils.isNotEmpty(env)) {
for (Map.Entry ee : env.entrySet()) {
setEnv(ee.getKey(), ee.getValue());
}
@@ -275,7 +276,7 @@ protected void doOpenPty() throws IOException {
buffer.putInt(getPtyWidth());
Map ptyModes = getPtyModes();
- int numModes = GenericUtils.size(ptyModes);
+ int numModes = MapEntryUtils.size(ptyModes);
Buffer modes = new ByteArrayBuffer(numModes * (1 + Integer.BYTES) + Long.SIZE, false);
if (numModes > 0) {
ptyModes.forEach((mode, value) -> {
@@ -288,7 +289,7 @@ protected void doOpenPty() throws IOException {
writePacket(buffer);
}
- if (GenericUtils.size(env) > 0) {
+ if (MapEntryUtils.size(env) > 0) {
if (debugEnabled) {
log.debug("doOpenPty({}) Send SSH_MSG_CHANNEL_REQUEST env: {}", this, env);
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/SshClientConfigFileReader.java b/sshd-core/src/main/java/org/apache/sshd/client/config/SshClientConfigFileReader.java
index 742cda469..24878ea92 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/config/SshClientConfigFileReader.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/config/SshClientConfigFileReader.java
@@ -30,6 +30,7 @@
import org.apache.sshd.common.config.SshConfigFileReader;
import org.apache.sshd.common.session.SessionHeartbeatController.HeartbeatType;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.core.CoreModuleProperties;
/**
@@ -79,7 +80,7 @@ public static C setupClientHeartbeat(C client, PropertyRes
}
public static C setupClientHeartbeat(C client, Map options) {
- if ((client == null) || GenericUtils.isEmpty(options)) {
+ if ((client == null) || MapEntryUtils.isEmpty(options)) {
return client;
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
index b81ac20b7..c40ca7f6f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
@@ -71,6 +71,7 @@
import org.apache.sshd.common.session.SessionDisconnectHandler;
import org.apache.sshd.common.session.helpers.AbstractConnectionService;
import org.apache.sshd.common.session.helpers.AbstractSession;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
@@ -689,7 +690,7 @@ public KeyExchangeFuture switchToNoneCipher() throws IOException {
setKexSeed(seed);
}
} catch (Exception e) {
- GenericUtils.rethrowAsIoException(e);
+ ExceptionUtils.rethrowAsIoException(e);
}
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClientSessionCreator.java b/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClientSessionCreator.java
index e32bf2818..dd0813024 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClientSessionCreator.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClientSessionCreator.java
@@ -31,7 +31,7 @@
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.client.session.ClientSessionCreator;
import org.apache.sshd.common.AttributeRepository;
-import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.ValidateUtils;
/**
@@ -120,13 +120,13 @@ protected ClientSession authSession(ClientSession clientSession) throws IOExcept
auth.verify(getAuthenticationTimeout());
session = null; // disable auto-close
} catch (IOException e) {
- err = GenericUtils.accumulateException(err, e);
+ err = ExceptionUtils.accumulateException(err, e);
} finally {
if (session != null) {
try {
session.close();
} catch (IOException e) {
- err = GenericUtils.accumulateException(err, e);
+ err = ExceptionUtils.accumulateException(err, e);
}
}
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
index f888d74c6..01238f7ce 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
@@ -51,15 +51,16 @@
import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.EventListenerUtils;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.Int2IntFunction;
-import org.apache.sshd.common.util.Invoker;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.BufferUtils;
import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
import org.apache.sshd.common.util.closeable.IoBaseCloseable;
+import org.apache.sshd.common.util.functors.Int2IntFunction;
import org.apache.sshd.common.util.io.IoUtils;
+import org.apache.sshd.common.util.io.functors.Invoker;
import org.apache.sshd.common.util.threads.CloseableExecutorService;
import org.apache.sshd.common.util.threads.ExecutorServiceCarrier;
import org.apache.sshd.core.CoreModuleProperties;
@@ -381,7 +382,7 @@ protected void signalChannelInitialized() throws IOException {
notifyStateChanged("init");
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
if (e instanceof IOException) {
throw (IOException) e;
} else if (e instanceof RuntimeException) {
@@ -455,7 +456,7 @@ protected void signalChannelOpenFailure(Throwable reason) {
return null;
});
} catch (Throwable err) {
- Throwable ignored = GenericUtils.peelException(err);
+ Throwable ignored = ExceptionUtils.peelException(err);
debug("signalChannelOpenFailure({}) failed ({}) to inform listener of open failure={}: {}", this,
ignored.getClass().getSimpleName(), reason.getClass().getSimpleName(), ignored.getMessage(),
ignored);
@@ -477,7 +478,7 @@ protected void notifyStateChanged(String hint) {
return null;
});
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
debug("notifyStateChanged({})[{}] {} while signal channel state change: {}", this, hint,
e.getClass().getSimpleName(), e.getMessage(), e);
} finally {
@@ -726,7 +727,7 @@ public void signalChannelClosed(Throwable reason) {
return null;
});
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
debug("signalChannelClosed({}) {} while signal channel closed: {}", this, e.getClass().getSimpleName(),
e.getMessage(), e);
} finally {
@@ -757,7 +758,7 @@ protected void invokeChannelSignaller(Invoker invoker) th
try {
invoker.invoke(l);
} catch (Throwable t) {
- err = GenericUtils.accumulateException(err, t);
+ err = ExceptionUtils.accumulateException(err, t);
}
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
index e8b81d8b2..477852e67 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
@@ -34,10 +34,10 @@
import org.apache.sshd.common.future.SshFutureListener;
import org.apache.sshd.common.io.IoOutputStream;
import org.apache.sshd.common.io.IoWriteFuture;
-import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
+import org.apache.sshd.common.util.functors.UnaryEquator;
import org.apache.sshd.core.CoreModuleProperties;
/**
@@ -167,7 +167,7 @@ protected void startWriting() throws IOException {
IoWriteFutureImpl currentFuture = currentWrite.getAndSet(null);
for (IoWriteFutureImpl pendingWrite : writes) {
// Checking reference by design
- if (GenericUtils.isSameReference(pendingWrite, currentFuture)) {
+ if (UnaryEquator.isSameReference(pendingWrite, currentFuture)) {
continue; // will be taken care of when its listener is eventually called
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java
index c1d24f1df..1c25ec184 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java
@@ -58,13 +58,14 @@
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionHolder;
import org.apache.sshd.common.util.EventListenerUtils;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.Invoker;
import org.apache.sshd.common.util.Readable;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
+import org.apache.sshd.common.util.io.functors.Invoker;
import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.core.CoreModuleProperties;
import org.apache.sshd.server.forward.TcpForwardingFilter;
@@ -874,15 +875,15 @@ protected void invokePortEventListenerSignaller(InvokerNote: experimental - used for development purposes and as an example
- *
+ *
* @author Apache MINA SSHD Project
*/
public class DefaultClientKexExtensionHandler extends AbstractLoggingBean implements KexExtensionHandler {
@@ -91,7 +93,7 @@ public boolean isKexExtensionsAvailable(Session session, AvailabilityPhase phase
// Check if client already sent its proposal - if not, we can still influence it
Map clientProposal = session.getAttribute(CLIENT_PROPOSAL_KEY);
Map serverProposal = session.getAttribute(SERVER_PROPOSAL_KEY);
- if (GenericUtils.isNotEmpty(clientProposal)) {
+ if (MapEntryUtils.isNotEmpty(clientProposal)) {
if (debugEnabled) {
log.debug("isKexExtensionsAvailable({})[{}] already sent proposal={} (server={})",
session, phase, clientProposal, serverProposal);
@@ -108,7 +110,7 @@ public boolean isKexExtensionsAvailable(Session session, AvailabilityPhase phase
*
* Therefore we want to be sure the server declared its support for extensions before we declare ours.
*/
- if (GenericUtils.isEmpty(serverProposal)) {
+ if (MapEntryUtils.isEmpty(serverProposal)) {
if (debugEnabled) {
log.debug("isKexExtensionsAvailable({})[{}] no server proposal", session, phase);
}
@@ -164,7 +166,7 @@ public List> updateAvailableSignatureFactories(
throws IOException {
List> available = session.getSignatureFactories();
List> updated = resolveUpdatedSignatureFactories(session, available, extraAlgos);
- if (!GenericUtils.isSameReference(available, updated)) {
+ if (!UnaryEquator.isSameReference(available, updated)) {
if (log.isDebugEnabled()) {
log.debug("updateAvailableSignatureFactories({}) available={}, updated={}",
session, available, updated);
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
index d1f3ac01b..147ef16f7 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
@@ -62,10 +62,10 @@
import org.apache.sshd.common.session.UnknownChannelReferenceHandler;
import org.apache.sshd.common.util.EventListenerUtils;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.Int2IntFunction;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
+import org.apache.sshd.common.util.functors.Int2IntFunction;
import org.apache.sshd.core.CoreModuleProperties;
import org.apache.sshd.server.x11.DefaultX11ForwardSupport;
import org.apache.sshd.server.x11.X11ForwardSupport;
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
index 41eae682c..7a01066e0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
@@ -79,6 +79,7 @@
import org.apache.sshd.common.session.SessionListener;
import org.apache.sshd.common.session.SessionWorkBuffer;
import org.apache.sshd.common.util.EventListenerUtils;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.NumberUtils;
import org.apache.sshd.common.util.Readable;
@@ -898,7 +899,7 @@ public IoWriteFuture writePacket(Buffer buffer) throws IOException {
+ " to check re-key necessity: " + e.getMessage()),
e);
} catch (Exception e) {
- GenericUtils.rethrowAsIoException(e);
+ ExceptionUtils.rethrowAsIoException(e);
}
}
}
@@ -2119,7 +2120,7 @@ public KeyExchangeFuture reExchangeKeys() throws IOException {
+ " to generate keys for exchange: " + e.getMessage()),
e);
} catch (Exception e) {
- GenericUtils.rethrowAsIoException(e);
+ ExceptionUtils.rethrowAsIoException(e);
return null; // actually dead code
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
index 4de89bfdd..09a7a47b3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
@@ -66,12 +66,14 @@
import org.apache.sshd.common.session.SessionListener;
import org.apache.sshd.common.session.UnknownChannelReferenceHandler;
import org.apache.sshd.common.session.helpers.TimeoutIndicator.TimeoutStatus;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.Invoker;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.BufferUtils;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.io.functors.Invoker;
import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.core.CoreModuleProperties;
@@ -217,7 +219,7 @@ public void setAuthenticated() throws IOException {
try {
signalSessionEvent(SessionListener.Event.Authenticated);
} catch (Exception e) {
- GenericUtils.rethrowAsIoException(e);
+ ExceptionUtils.rethrowAsIoException(e);
}
}
@@ -571,7 +573,7 @@ protected void signalSessionEstablished(IoSession ioSession) throws Exception {
return null;
});
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
debug("Failed ({}) to announce session={} established: {}",
e.getClass().getSimpleName(), ioSession, e.getMessage(), e);
if (e instanceof Exception) {
@@ -596,7 +598,7 @@ protected void signalSessionCreated(IoSession ioSession) throws Exception {
return null;
});
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
debug("Failed ({}) to announce session={} created: {}",
e.getClass().getSimpleName(), ioSession, e.getMessage(), e);
if (e instanceof Exception) {
@@ -621,7 +623,7 @@ protected void signalSendIdentification(String version, List extraLines)
return null;
});
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
if (e instanceof Exception) {
throw (Exception) e;
} else {
@@ -645,7 +647,7 @@ protected void signalReadPeerIdentificationLine(String line, List extraL
return null;
});
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
debug("signalReadPeerIdentificationLine({}) Failed ({}) to announce peer={}: {}",
this, e.getClass().getSimpleName(), line, e.getMessage(), e);
if (e instanceof Exception) {
@@ -672,7 +674,7 @@ protected void signalPeerIdentificationReceived(String version, List ext
return null;
});
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
debug("signalPeerIdentificationReceived({}) Failed ({}) to announce peer={}: {}",
this, e.getClass().getSimpleName(), version, e.getMessage(), e);
if (e instanceof Exception) {
@@ -705,7 +707,7 @@ protected void signalSessionEvent(SessionListener.Event event) throws Exception
return null;
});
} catch (Throwable err) {
- Throwable t = GenericUtils.peelException(err);
+ Throwable t = ExceptionUtils.peelException(err);
debug("sendSessionEvent({})[{}] failed ({}) to inform listeners: {}",
this, event, t.getClass().getSimpleName(), t.getMessage(), t);
if (t instanceof Exception) {
@@ -740,7 +742,7 @@ protected void invokeSessionSignaller(Invoker invoker) th
try {
invoker.invoke(l);
} catch (Throwable t) {
- err = GenericUtils.accumulateException(err, t);
+ err = ExceptionUtils.accumulateException(err, t);
}
}
@@ -1005,7 +1007,7 @@ protected Map mergeProposals(
current.clear(); // debug breakpoint
}
- if (GenericUtils.isEmpty(proposal)) {
+ if (MapEntryUtils.isEmpty(proposal)) {
return proposal; // debug breakpoint
}
@@ -1022,7 +1024,7 @@ protected void signalNegotiationOptionsCreated(Map pr
return null;
});
} catch (Throwable t) {
- Throwable err = GenericUtils.peelException(t);
+ Throwable err = ExceptionUtils.peelException(t);
if (err instanceof RuntimeException) {
throw (RuntimeException) err;
} else if (err instanceof Error) {
@@ -1049,7 +1051,7 @@ protected void signalNegotiationStart(
return null;
});
} catch (Throwable t) {
- Throwable err = GenericUtils.peelException(t);
+ Throwable err = ExceptionUtils.peelException(t);
if (err instanceof RuntimeException) {
throw (RuntimeException) err;
} else if (err instanceof Error) {
@@ -1078,7 +1080,7 @@ protected void signalNegotiationEnd(
return null;
});
} catch (Throwable t) {
- Throwable err = GenericUtils.peelException(t);
+ Throwable err = ExceptionUtils.peelException(t);
if (err instanceof RuntimeException) {
throw (RuntimeException) err;
} else if (err instanceof Error) {
@@ -1196,7 +1198,7 @@ protected void signalDisconnect(int code, String msg, String lang, boolean initi
return null;
});
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
debug("signalDisconnect({}) {}: {}",
this, e.getClass().getSimpleName(), e.getMessage(), e);
}
@@ -1256,7 +1258,7 @@ protected void signalExceptionCaught(Throwable t) {
return null;
});
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
debug("signalExceptionCaught({}) {}: {}",
this, e.getClass().getSimpleName(), e.getMessage(), e);
}
@@ -1277,7 +1279,7 @@ protected void signalSessionClosed() {
return null;
});
} catch (Throwable err) {
- Throwable e = GenericUtils.peelException(err);
+ Throwable e = ExceptionUtils.peelException(err);
debug("signalSessionClosed({}) {} while signal session closed: {}",
this, e.getClass().getSimpleName(), e.getMessage(), e);
// Do not re-throw since session closed anyway
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AuthorizedKeyEntriesPublickeyAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AuthorizedKeyEntriesPublickeyAuthenticator.java
index 806497193..de11dbda9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AuthorizedKeyEntriesPublickeyAuthenticator.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/AuthorizedKeyEntriesPublickeyAuthenticator.java
@@ -32,6 +32,7 @@
import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.config.keys.PublicKeyEntryResolver;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.logging.AbstractLoggingBean;
import org.apache.sshd.server.session.ServerSession;
@@ -78,7 +79,7 @@ public Object getId() {
@Override
public boolean authenticate(String username, PublicKey key, ServerSession session) {
- if (GenericUtils.isEmpty(resolvedKeys)) {
+ if (MapEntryUtils.isEmpty(resolvedKeys)) {
if (log.isDebugEnabled()) {
log.debug("authenticate(" + username + ")[" + session + "] no entries");
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
index 45839424c..788ac55ba 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
@@ -33,7 +33,7 @@
import org.apache.sshd.common.channel.RequestHandler;
import org.apache.sshd.common.channel.Window;
import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.threads.CloseableExecutorService;
@@ -87,7 +87,7 @@ protected OpenFuture doInit(Buffer buffer) {
signalChannelOpenSuccess();
f.setOpened();
} catch (Throwable t) {
- Throwable e = GenericUtils.peelException(t);
+ Throwable e = ExceptionUtils.peelException(t);
changeEvent = e.getClass().getSimpleName();
signalChannelOpenFailure(e);
f.setException(e);
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
index 8ad6254a4..310a8e47c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
@@ -29,6 +29,7 @@
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionContext;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.buffer.Buffer;
/**
@@ -113,7 +114,7 @@ public static boolean isPuttyClient(String clientVersion) {
public static Map resolveShellTtyOptions(Map modes) {
Map resolved = PtyMode.createEnabledOptions(PUTTY_OPTIONS);
- if (GenericUtils.size(modes) > 0) {
+ if (MapEntryUtils.size(modes) > 0) {
resolved.putAll(modes); // TODO consider adding only non-overriding options
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/config/SshServerConfigFileReader.java b/sshd-core/src/main/java/org/apache/sshd/server/config/SshServerConfigFileReader.java
index 9eb79aa32..8a7057efc 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/config/SshServerConfigFileReader.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/config/SshServerConfigFileReader.java
@@ -29,6 +29,7 @@
import org.apache.sshd.common.config.SshConfigFileReader;
import org.apache.sshd.common.session.SessionHeartbeatController.HeartbeatType;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.core.CoreModuleProperties;
import org.apache.sshd.server.ServerBuilder;
@@ -81,7 +82,7 @@ public static S setupServerHeartbeat(S server,
}
public static S setupServerHeartbeat(S server, Map options) {
- if ((server == null) || GenericUtils.isEmpty(options)) {
+ if ((server == null) || MapEntryUtils.isEmpty(options)) {
return server;
}
@@ -110,7 +111,7 @@ public static S configure(
}
public static ForwardingFilter resolveServerForwarding(PropertyResolver options) {
- if (GenericUtils.isEmpty(options)) {
+ if (PropertyResolver.isEmpty(options)) {
return AcceptAllForwardingFilter.INSTANCE;
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/config/keys/ServerIdentity.java b/sshd-core/src/main/java/org/apache/sshd/server/config/keys/ServerIdentity.java
index 8b08ca9ac..c1b38a9de 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/config/keys/ServerIdentity.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/config/keys/ServerIdentity.java
@@ -36,6 +36,7 @@
import org.apache.sshd.common.config.keys.IdentityUtils;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.io.IoUtils;
import org.apache.sshd.server.SshServer;
@@ -154,7 +155,7 @@ public static Map findCertificates(Properties props, LinkOption...
private static Map getLocations(String configPropKey, Properties props, LinkOption... options)
throws IOException {
- if (GenericUtils.isEmpty(props)) {
+ if (MapEntryUtils.isEmpty(props)) {
return Collections.emptyMap();
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index 0581ed4cf..7ea6c7221 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -52,7 +52,7 @@
import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.io.IoWriteFuture;
import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.Readable;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
@@ -305,12 +305,12 @@ protected void handleChannelConnectResult(OpenFuture f, IoConnectFuture future)
return;
}
- Throwable problem = GenericUtils.peelException(future.getException());
+ Throwable problem = ExceptionUtils.peelException(future.getException());
if (problem != null) {
handleChannelOpenFailure(f, problem);
}
} catch (RuntimeException t) {
- Throwable e = GenericUtils.peelException(t);
+ Throwable e = ExceptionUtils.peelException(t);
signalChannelOpenFailure(e);
try {
f.setException(e);
@@ -328,7 +328,7 @@ protected void handleChannelOpenSuccess(OpenFuture f, IoSession session) {
signalChannelOpenSuccess();
f.setOpened();
} catch (Throwable t) {
- Throwable e = GenericUtils.peelException(t);
+ Throwable e = ExceptionUtils.peelException(t);
changeEvent = e.getClass().getSimpleName();
signalChannelOpenFailure(e);
f.setException(e);
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
index d06fb0a2f..a2fc22628 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
@@ -26,8 +26,8 @@
import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.helpers.AbstractConnectionServiceRequestHandler;
-import org.apache.sshd.common.util.Int2IntFunction;
import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.functors.Int2IntFunction;
import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
index 9ccac7d2e..b64d1b242 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
@@ -26,8 +26,8 @@
import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.helpers.AbstractConnectionServiceRequestHandler;
-import org.apache.sshd.common.util.Int2IntFunction;
import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.functors.Int2IntFunction;
import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
index 5cff5f9cd..bb0fbe553 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
@@ -56,6 +56,7 @@
import org.apache.sshd.common.session.helpers.AbstractSession;
import org.apache.sshd.common.signature.SignatureFactory;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
@@ -552,7 +553,7 @@ public int getActiveSessionCountForUser(String userName) {
IoSession networkSession = getIoSession();
IoService service = networkSession.getService();
Map, IoSession> sessionsMap = service.getManagedSessions();
- if (GenericUtils.isEmpty(sessionsMap)) {
+ if (MapEntryUtils.isEmpty(sessionsMap)) {
return 0;
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java
index 29b657384..02762c558 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java
@@ -27,6 +27,7 @@
import java.util.concurrent.ExecutorService;
import org.apache.sshd.common.RuntimeSshException;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.logging.AbstractLoggingBean;
@@ -148,7 +149,7 @@ public synchronized void destroy(ChannelSession channel) throws Exception {
} catch (Throwable e) {
warn("destroy({}) failed ({}) to destroy shell: {}",
this, e.getClass().getSimpleName(), e.getMessage(), e);
- err = GenericUtils.accumulateException(err, e);
+ err = ExceptionUtils.accumulateException(err, e);
}
if (shutdownExecutor && (executor instanceof ExecutorService)) {
@@ -157,7 +158,7 @@ public synchronized void destroy(ChannelSession channel) throws Exception {
} catch (Exception e) {
warn("destroy({}) failed ({}) to shut down executor: {}",
this, e.getClass().getSimpleName(), e.getMessage(), e);
- err = GenericUtils.accumulateException(err, e);
+ err = ExceptionUtils.accumulateException(err, e);
}
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java
index 0bb881c91..32a93ccf8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java
@@ -31,6 +31,7 @@
import org.apache.sshd.common.channel.PtyMode;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.io.IoUtils;
import org.apache.sshd.common.util.logging.AbstractLoggingBean;
@@ -100,7 +101,7 @@ public void start(ChannelSession channel, Environment env) throws IOException {
}
ProcessBuilder builder = new ProcessBuilder(command);
- if (GenericUtils.size(varsMap) > 0) {
+ if (MapEntryUtils.size(varsMap) > 0) {
try {
Map procEnv = builder.environment();
procEnv.putAll(varsMap);
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifierTest.java b/sshd-core/src/test/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifierTest.java
index 98fd5b07b..67cdba0c8 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifierTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifierTest.java
@@ -50,6 +50,7 @@
import org.apache.sshd.common.mac.Mac;
import org.apache.sshd.common.random.JceRandomFactory;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.util.test.BaseTestSupport;
@@ -395,7 +396,7 @@ private void testUpdateSameHostWithDifferentPorts(int port1, int port2, boolean
assertTrue("Accepted on port=" + port2 + " ?", accepted2);
Map updatedKeys = loadEntries(path);
- assertEquals("Mismatched total entries count", 2, GenericUtils.size(updatedKeys));
+ assertEquals("Mismatched total entries count", 2, MapEntryUtils.size(updatedKeys));
}
private Path createKnownHostsCopy() throws IOException {
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java
index 323fbaf0e..92471c924 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java
@@ -29,7 +29,7 @@
import java.util.concurrent.TimeUnit;
import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.util.test.JUnitTestSupport;
import org.apache.sshd.util.test.NoIoTestCase;
import org.junit.FixMethodOrder;
@@ -66,7 +66,7 @@ public void testResolveAndUpdateClosestPropertyValue() {
public void testSyspropsResolver() {
PropertyResolver resolver = SyspropsMapWrapper.SYSPROPS_RESOLVER;
Map props = resolver.getProperties();
- assertTrue("Unexpected initial resolver values: " + props, GenericUtils.isEmpty(props));
+ assertTrue("Unexpected initial resolver values: " + props, MapEntryUtils.isEmpty(props));
final String propName = getCurrentTestName();
assertNull("Unexpected initial resolved value", PropertyResolverUtils.getObject(resolver, propName));
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/auth/KeyboardInteractiveAuthenticationTest.java b/sshd-core/src/test/java/org/apache/sshd/common/auth/KeyboardInteractiveAuthenticationTest.java
index feeabf381..5a3785724 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/auth/KeyboardInteractiveAuthenticationTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/auth/KeyboardInteractiveAuthenticationTest.java
@@ -32,6 +32,7 @@
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.MapEntryUtils.NavigableMapBuilder;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.core.CoreModuleProperties;
@@ -161,7 +162,7 @@ public boolean authenticate(
ServerSession session, String username, List responses)
throws Exception {
assertEquals("Unexpected authenticate call", 1, authCount.incrementAndGet());
- assertEquals("Mismatched number of responses", GenericUtils.size(rspMap), GenericUtils.size(responses));
+ assertEquals("Mismatched number of responses", MapEntryUtils.size(rspMap), GenericUtils.size(responses));
int index = 0;
// Cannot use forEach because the index is not effectively final
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
index c70e303ec..f9f1eadfe 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
@@ -65,6 +65,7 @@
import org.apache.sshd.common.session.helpers.TimeoutIndicator;
import org.apache.sshd.common.session.helpers.TimeoutIndicator.TimeoutStatus;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.MapEntryUtils.NavigableMapBuilder;
import org.apache.sshd.common.util.OsUtils;
import org.apache.sshd.core.CoreModuleProperties;
@@ -774,7 +775,7 @@ public void start(ChannelSession channel, Environment env) throws IOException {
assertNotNull("No environment set", cmdEnv);
Map vars = cmdEnv.getEnv();
- assertTrue("Mismatched vars count", GenericUtils.size(vars) >= GenericUtils.size(expected));
+ assertTrue("Mismatched vars count", MapEntryUtils.size(vars) >= MapEntryUtils.size(expected));
expected.forEach((key, expValue) -> {
String actValue = vars.get(key);
assertEquals("Mismatched value for " + key, expValue, actValue);
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/config/keys/ServerIdentityTest.java b/sshd-core/src/test/java/org/apache/sshd/server/config/keys/ServerIdentityTest.java
index 1665dc922..fb57a6dda 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/config/keys/ServerIdentityTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/config/keys/ServerIdentityTest.java
@@ -33,6 +33,7 @@
import org.apache.sshd.common.config.keys.IdentityUtils;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.io.IoUtils;
import org.apache.sshd.util.test.BaseTestSupport;
import org.apache.sshd.util.test.NoIoTestCase;
@@ -78,7 +79,7 @@ public void testLoadServerIdentities() throws Exception {
props.setProperty(ServerIdentity.HOST_KEY_CONFIG_PROP, GenericUtils.join(paths, ','));
Map ids = ServerIdentity.loadIdentities(props, options);
- assertEquals("Mismatched loaded ids count", GenericUtils.size(paths), GenericUtils.size(ids));
+ assertEquals("Mismatched loaded ids count", GenericUtils.size(paths), MapEntryUtils.size(ids));
Collection pairs = new ArrayList<>(ids.size());
for (BuiltinIdentities type : BuiltinIdentities.VALUES) {
diff --git a/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionFactory.java b/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionFactory.java
index c793ab35e..f4b0b81f7 100644
--- a/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionFactory.java
+++ b/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionFactory.java
@@ -25,7 +25,7 @@
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.client.session.ClientSessionHolder;
import org.apache.sshd.common.session.SessionHolder;
-import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.functors.UnaryEquator;
import org.eclipse.jgit.errors.TransportException;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.RemoteSession;
@@ -113,7 +113,7 @@ protected ClientSession createClientSession(
@Override
protected void disconnectSession(ClientSession sessionInstance) {
ClientSession thisSession = getClientSession();
- if (GenericUtils.isSameReference(thisSession, sessionInstance)) {
+ if (UnaryEquator.isSameReference(thisSession, sessionInstance)) {
return; // do not use the session instance we were given
}
@@ -123,7 +123,7 @@ protected void disconnectSession(ClientSession sessionInstance) {
@Override
protected void disconnectClient(SshClient clientInstance) {
SshClient thisClient = getClient();
- if (GenericUtils.isSameReference(thisClient, clientInstance)) {
+ if (UnaryEquator.isSameReference(thisClient, clientInstance)) {
return; // do not close the client the user gave us
}
diff --git a/sshd-ldap/src/test/java/org/apache/sshd/ldap/LdapPasswordAuthenticatorTest.java b/sshd-ldap/src/test/java/org/apache/sshd/ldap/LdapPasswordAuthenticatorTest.java
index a40978ca0..13b260da7 100644
--- a/sshd-ldap/src/test/java/org/apache/sshd/ldap/LdapPasswordAuthenticatorTest.java
+++ b/sshd-ldap/src/test/java/org/apache/sshd/ldap/LdapPasswordAuthenticatorTest.java
@@ -27,7 +27,7 @@
import org.apache.directory.server.core.annotations.CreateDS;
import org.apache.directory.server.core.annotations.CreatePartition;
import org.apache.directory.server.core.integ.CreateLdapServerRule;
-import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.server.session.ServerSession;
import org.junit.ClassRule;
import org.junit.FixMethodOrder;
@@ -59,7 +59,7 @@ public LdapPasswordAuthenticatorTest() {
public void testPasswordComparison() throws Exception {
usersMap = populateUsers(serverRule.getLdapServer().getDirectoryService(),
LdapPasswordAuthenticatorTest.class, LdapPasswordAuthenticator.DEFAULT_PASSWORD_ATTR_NAME);
- assertFalse("No users retrieved", GenericUtils.isEmpty(usersMap));
+ assertFalse("No users retrieved", MapEntryUtils.isEmpty(usersMap));
LdapPasswordAuthenticator auth = new LdapPasswordAuthenticator();
auth.setHost(getHost(serverRule.getLdapServer()));
diff --git a/sshd-ldap/src/test/java/org/apache/sshd/ldap/LdapPublickeyAuthenticatorTest.java b/sshd-ldap/src/test/java/org/apache/sshd/ldap/LdapPublickeyAuthenticatorTest.java
index b7f1ac79e..1d899e714 100644
--- a/sshd-ldap/src/test/java/org/apache/sshd/ldap/LdapPublickeyAuthenticatorTest.java
+++ b/sshd-ldap/src/test/java/org/apache/sshd/ldap/LdapPublickeyAuthenticatorTest.java
@@ -35,7 +35,7 @@
import org.apache.sshd.common.config.keys.AuthorizedKeyEntry;
import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.config.keys.PublicKeyEntryResolver;
-import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.server.session.ServerSession;
import org.junit.ClassRule;
import org.junit.FixMethodOrder;
@@ -69,7 +69,7 @@ public LdapPublickeyAuthenticatorTest() {
public void testPublicKeyComparison() throws Exception {
Map credentials = populateUsers(serverRule.getLdapServer().getDirectoryService(),
LdapPublickeyAuthenticatorTest.class, TEST_ATTR_NAME);
- assertFalse("No keys retrieved", GenericUtils.isEmpty(credentials));
+ assertFalse("No keys retrieved", MapEntryUtils.isEmpty(credentials));
// Cannot use forEach because of the potential GeneraSecurityException being thrown
for (Map.Entry ce : credentials.entrySet()) {
diff --git a/sshd-mina/src/main/java/org/apache/sshd/mina/MinaService.java b/sshd-mina/src/main/java/org/apache/sshd/mina/MinaService.java
index 99f471204..77c0a9aaf 100644
--- a/sshd-mina/src/main/java/org/apache/sshd/mina/MinaService.java
+++ b/sshd-mina/src/main/java/org/apache/sshd/mina/MinaService.java
@@ -37,7 +37,7 @@
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.Property;
import org.apache.sshd.common.io.IoServiceEventListener;
-import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.Readable;
import org.apache.sshd.common.util.closeable.AbstractCloseable;
import org.apache.sshd.core.CoreModuleProperties;
@@ -213,7 +213,7 @@ protected void configure(SocketSessionConfig config) {
protected void handleConfigurationError(
SocketSessionConfig config, Property> property, Object propValue, RuntimeIoException t) {
- Throwable e = GenericUtils.resolveExceptionCause(t);
+ Throwable e = ExceptionUtils.resolveExceptionCause(t);
log.warn("handleConfigurationError({}={}) failed ({}) to configure: {}",
property.getName(), propValue, e.getClass().getSimpleName(), e.getMessage());
}
diff --git a/sshd-mina/src/main/java/org/apache/sshd/mina/MinaSession.java b/sshd-mina/src/main/java/org/apache/sshd/mina/MinaSession.java
index 04c7ea7ae..722d82e08 100644
--- a/sshd-mina/src/main/java/org/apache/sshd/mina/MinaSession.java
+++ b/sshd-mina/src/main/java/org/apache/sshd/mina/MinaSession.java
@@ -39,7 +39,7 @@
import org.apache.sshd.common.io.IoService;
import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.io.IoWriteFuture;
-import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.NumberUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
@@ -228,7 +228,7 @@ public void shutdownOutputStream() throws IOException {
try {
channel = (Channel) NIO_SESSION_CHANNEL_FIELD.get(session);
} catch (Exception t) {
- Throwable e = GenericUtils.peelException(t);
+ Throwable e = ExceptionUtils.peelException(t);
log.warn("shudownOutputStream({}) failed ({}) to retrieve embedded channel: {}",
session, e.getClass().getSimpleName(), e.getMessage());
return;
diff --git a/sshd-netty/src/main/java/org/apache/sshd/netty/NettyIoSession.java b/sshd-netty/src/main/java/org/apache/sshd/netty/NettyIoSession.java
index 01ab21d0c..143e66191 100644
--- a/sshd-netty/src/main/java/org/apache/sshd/netty/NettyIoSession.java
+++ b/sshd-netty/src/main/java/org/apache/sshd/netty/NettyIoSession.java
@@ -47,6 +47,7 @@
import org.apache.sshd.common.io.IoService;
import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.io.IoWriteFuture;
+import org.apache.sshd.common.util.ExceptionUtils;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.closeable.AbstractCloseable;
@@ -186,7 +187,7 @@ public void shutdownOutputStream() throws IOException {
try {
channel = (SelectableChannel) NIO_JAVA_CHANNEL_METHOD.invoke(ch, GenericUtils.EMPTY_OBJECT_ARRAY);
} catch (Exception t) {
- Throwable e = GenericUtils.peelException(t);
+ Throwable e = ExceptionUtils.peelException(t);
log.warn("shudownOutputStream({}) failed ({}) to retrieve embedded channel: {}",
this, e.getClass().getSimpleName(), e.getMessage());
return;
diff --git a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedEntriesTracker.java b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedEntriesTracker.java
index 70b0f93a2..8788b1876 100644
--- a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedEntriesTracker.java
+++ b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedEntriesTracker.java
@@ -38,6 +38,7 @@
import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.session.SessionContext;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.io.resource.PathResource;
import org.apache.sshd.common.util.logging.AbstractLoggingBean;
import org.apache.sshd.common.util.security.SecurityUtils;
@@ -123,7 +124,7 @@ public List loadMatchingKeyFingerprints(
PathResource resourceKey = f.toPathResource();
Key container = f.loadPublicKey(session, resourceKey, provider);
Map fpMap = PGPUtils.mapSubKeysByFingerprint(container);
- int numSubKeys = GenericUtils.size(fpMap);
+ int numSubKeys = MapEntryUtils.size(fpMap);
Collection matches = (numSubKeys <= 0)
? Collections.emptyList()
: fpMap.entrySet()
diff --git a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedKeyEntriesLoader.java b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedKeyEntriesLoader.java
index 3f9225ce1..11fcdacc8 100644
--- a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedKeyEntriesLoader.java
+++ b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedKeyEntriesLoader.java
@@ -36,6 +36,7 @@
import org.apache.sshd.common.keyprovider.KeyTypeIndicator;
import org.apache.sshd.common.session.SessionContext;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.bouncycastle.openpgp.PGPException;
/**
@@ -82,7 +83,7 @@ default List resolveAuthorizedEntries(
SessionContext session, Collection extends PublicKeyEntry> entries, PublicKeyEntryResolver fallbackResolver)
throws IOException, GeneralSecurityException, PGPException {
Map> typesMap = KeyTypeIndicator.groupByKeyType(entries);
- if (GenericUtils.isEmpty(typesMap)) {
+ if (MapEntryUtils.isEmpty(typesMap)) {
return Collections.emptyList();
}
diff --git a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPPublicRingWatcher.java b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPPublicRingWatcher.java
index 8855e7d8b..76113385a 100644
--- a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPPublicRingWatcher.java
+++ b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPPublicRingWatcher.java
@@ -41,6 +41,8 @@
import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.session.SessionContext;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
+import org.apache.sshd.common.util.functors.UnaryEquator;
import org.apache.sshd.common.util.io.ModifiableFileWatcher;
import org.apache.sshd.common.util.io.resource.IoResource;
import org.apache.sshd.common.util.io.resource.PathResource;
@@ -86,7 +88,7 @@ public List loadMatchingKeyFingerprints(
}
Map keysMap = resolveRingKeys(session);
- if (GenericUtils.isEmpty(keysMap)) {
+ if (MapEntryUtils.isEmpty(keysMap)) {
return Collections.emptyList();
}
@@ -109,7 +111,7 @@ public List loadMatchingKeyFingerprints(
protected NavigableMap resolveRingKeys(SessionContext session)
throws IOException, GeneralSecurityException, PGPException {
NavigableMap keysMap = ringKeys.get();
- if (GenericUtils.isEmpty(keysMap) || checkReloadRequired()) {
+ if (MapEntryUtils.isEmpty(keysMap) || checkReloadRequired()) {
ringKeys.set(Collections.emptyNavigableMap()); // mark stale
if (!exists()) {
@@ -119,7 +121,7 @@ protected NavigableMap resolveRingKeys(SessionContext session
Path file = getPath();
keysMap = reloadRingKeys(session, new PathResource(file));
- int numKeys = GenericUtils.size(keysMap);
+ int numKeys = MapEntryUtils.size(keysMap);
if (log.isDebugEnabled()) {
log.debug("resolveRingKeys({}) reloaded {} keys from {}", session, numKeys, file);
}
@@ -184,7 +186,7 @@ protected NavigableMap reloadRingKeys(
PublicKey effective = handleDuplicateKeyFingerprint(session, resourceKey, fp, sk, prev, pubKey);
if (effective == null) {
keysMap.remove(fp);
- } else if (!GenericUtils.isSameReference(effective, pubKey)) {
+ } else if (!UnaryEquator.isSameReference(effective, pubKey)) {
keysMap.put(fp, effective);
}
}
diff --git a/sshd-openpgp/src/test/java/org/apache/sshd/openpgp/PGPPublicRingWatcherTest.java b/sshd-openpgp/src/test/java/org/apache/sshd/openpgp/PGPPublicRingWatcherTest.java
index 90868eb0b..fb8ebd77a 100644
--- a/sshd-openpgp/src/test/java/org/apache/sshd/openpgp/PGPPublicRingWatcherTest.java
+++ b/sshd-openpgp/src/test/java/org/apache/sshd/openpgp/PGPPublicRingWatcherTest.java
@@ -25,7 +25,7 @@
import java.util.NavigableMap;
import org.apache.sshd.common.config.keys.KeyUtils;
-import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.MapEntryUtils;
import org.apache.sshd.common.util.io.resource.PathResource;
import org.apache.sshd.util.test.CommonTestSupportUtils;
import org.apache.sshd.util.test.JUnitTestSupport;
@@ -62,7 +62,7 @@ public void testV1ResourcesKeyPath() throws Exception {
detectSourcesFolder(), TEST_SUBFOLDER, RESOURCES_SUBFOLDER, "keyring");
Path file = dir.resolve(PGPPublicRingWatcher.GPG_V1_PUBLIC_RING_FILENAME);
Map keys = testPublicRingWatcher(file);
- assertFalse("No keys extracted", GenericUtils.isEmpty(keys));
+ assertFalse("No keys extracted", MapEntryUtils.isEmpty(keys));
}
@Test
@@ -71,13 +71,13 @@ public void testV2ResourcesKeyPath() throws Exception {
detectSourcesFolder(), TEST_SUBFOLDER, RESOURCES_SUBFOLDER, "kbx2ring");
Path file = dir.resolve(PGPPublicRingWatcher.GPG_V2_PUBLIC_RING_FILENAME);
Map keys = testPublicRingWatcher(file);
- assertFalse("No keys extracted", GenericUtils.isEmpty(keys));
+ assertFalse("No keys extracted", MapEntryUtils.isEmpty(keys));
}
private NavigableMap testPublicRingWatcher(Path file) throws Exception {
PGPPublicRingWatcher watcher = new PGPPublicRingWatcher(file);
NavigableMap keys = watcher.reloadRingKeys(null, new PathResource(file));
- int numKeys = GenericUtils.size(keys);
+ int numKeys = MapEntryUtils.size(keys);
outputDebugMessage("%s: Loaded %d keys from %s", getCurrentTestName(), numKeys, file);
if (numKeys > 0) {
diff --git a/sshd-putty/src/test/java/org/apache/sshd/putty/PuttyKeyUtilsTest.java b/sshd-putty/src/test/java/org/apache/sshd/putty/PuttyKeyUtilsTest.java
index 239f3a073..25dd011a4 100644
--- a/sshd-putty/src/test/java/org/apache/sshd/putty/PuttyKeyUtilsTest.java
+++ b/sshd-putty/src/test/java/org/apache/sshd/putty/PuttyKeyUtilsTest.java
@@ -38,6 +38,7 @@
import org.apache.sshd.common.config.keys.loader.openssh.OpenSSHKeyPairResourceParser;
import org.apache.sshd.common.session.SessionContext;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.functors.UnaryEquator;
import org.apache.sshd.common.util.io.IoUtils;
import org.apache.sshd.util.test.JUnit4ClassRunnerWithParametersFactory;
import org.apache.sshd.util.test.JUnitTestSupport;
@@ -88,7 +89,7 @@ public static List