Skip to content

Commit ba100a5

Browse files
committed
Minor tweaks
1 parent 347d24a commit ba100a5

6 files changed

Lines changed: 12 additions & 15 deletions

File tree

sshd-cli/src/main/java/org/apache/sshd/cli/client/CliClientModuleProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public final class CliClientModuleProperties {
3131
* Key used to retrieve the value of the timeout after which it will abort the connection if the connection has not
3232
* been established - in milliseconds.
3333
*/
34-
public static final Property<Duration> CONECT_TIMEOUT
34+
public static final Property<Duration> CONNECT_TIMEOUT
3535
= Property.duration("cli-connect-timeout", Duration.ofMinutes(2));
3636

3737
/**

sshd-cli/src/main/java/org/apache/sshd/cli/client/ScpCommandMain.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,9 @@ public static void xferRemoteToRemote(
351351
HostConfigEntry entry = resolveHost(
352352
manager, target.resolveUsername(), target.getHost(), target.resolvePort(), null);
353353
// TODO use a configurable wait time
354-
ClientSession dstSession = manager.connect(entry, null, null)
355-
.verify(CliClientModuleProperties.CONECT_TIMEOUT.getRequired(srcSession))
356-
.getSession();
357-
try {
354+
try (ClientSession dstSession = manager.connect(entry, null, null)
355+
.verify(CliClientModuleProperties.CONNECT_TIMEOUT.getRequired(srcSession))
356+
.getSession()) {
358357
// TODO see if there is a way to specify different password/key for target
359358
// copy non-default identities from source session
360359
AuthenticationIdentitiesProvider provider = srcSession.getRegisteredIdentities();
@@ -431,8 +430,6 @@ private void logEvent(String event, String src, String dst, Throwable thrown) {
431430
} else {
432431
helper.transferFile(source.getPath(), target.getPath(), preserveAttributes);
433432
}
434-
} finally {
435-
dstSession.close();
436433
}
437434
} finally {
438435
srcSession.close();
@@ -488,7 +485,7 @@ public static void main(String[] args) throws Exception {
488485
defaultOptions);
489486
}
490487
} finally {
491-
if ((logStream != stdout) && (logStream != stderr)) {
488+
if ((logStream != stdout) && (logStream != stderr) && (logStream != null)) {
492489
logStream.close();
493490
}
494491
}

sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public static ClientSession setupClientSession(
268268

269269
HostConfigEntry entry = resolveHost(client, login, host, port, proxyJump);
270270
ClientSession session = client.connect(entry, null, null)
271-
.verify(CliClientModuleProperties.CONECT_TIMEOUT.getRequired(client))
271+
.verify(CliClientModuleProperties.CONNECT_TIMEOUT.getRequired(client))
272272
.getSession();
273273
try {
274274
if (GenericUtils.length(password) > 0) {
@@ -668,7 +668,7 @@ public static OutputStream resolveLoggingTargetStream(
668668

669669
String argVal = args[index + 1];
670670
if ("--".equals(argVal)) {
671-
return stdout;
671+
return new NoCloseOutputStream(stdout);
672672
}
673673

674674
try {
@@ -682,7 +682,7 @@ public static OutputStream resolveLoggingTargetStream(
682682
}
683683
}
684684

685-
return stderr;
685+
return new NoCloseOutputStream(stderr);
686686
}
687687

688688
public static Handler setupLogging(

sshd-core/src/main/java/org/apache/sshd/common/kex/extension/DefaultClientKexExtensionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public boolean handleKexExtensionRequest(
8989
log.debug("handleKexExtensionRequest({}) : ignoring unknown {} extension", session,
9090
HostBoundPubkeyAuthentication.NAME);
9191
}
92-
} else if (version.intValue() != 0) {
92+
} else if (version != 0) {
9393
if (log.isDebugEnabled()) {
9494
log.debug("handleKexExtensionRequest({}) : ignoring unknown {} version {}", session,
9595
HostBoundPubkeyAuthentication.NAME, version);

sshd-core/src/main/java/org/apache/sshd/common/kex/extension/DefaultServerKexExtensionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ public void handleKexInitProposal(Session session, boolean initiator, Map<KexPro
103103
public void sendKexExtensions(Session session, KexPhase phase) throws Exception {
104104
if (phase == KexPhase.NEWKEYS) {
105105
Boolean alreadySent = session.getAttribute(EXT_INFO_SENT_AT_NEWKEYS);
106-
if ((alreadySent != null) && alreadySent.booleanValue()) {
106+
if (alreadySent != null && alreadySent) {
107107
// It's not the first NEWKEYS.
108108
return;
109109
}
110110
session.setAttribute(EXT_INFO_SENT_AT_NEWKEYS, Boolean.TRUE);
111111
}
112112
Boolean doExtInfo = session.getAttribute(CLIENT_REQUESTED_EXT_INFO);
113-
if ((doExtInfo == null) || !doExtInfo.booleanValue()) {
113+
if (doExtInfo == null || !doExtInfo) {
114114
if (log.isTraceEnabled()) {
115115
log.trace("sendKexExtensions({})[{}]: client did not send ext-info-c; skipping sending SSH_MSG_EXT_INFO",
116116
session, phase);

sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,7 @@ protected Map<KexProposalOption, String> doStrictKexProposal(Map<KexProposalOpti
26752675
boolean changed = algorithms.remove(extType);
26762676
changed |= algorithms.remove(askForStrictKex);
26772677
if (changed) {
2678-
value = algorithms.stream().collect(Collectors.joining(","));
2678+
value = String.join(",", algorithms);
26792679
}
26802680
}
26812681
proposal.put(KexProposalOption.ALGORITHMS, value);

0 commit comments

Comments
 (0)