From cbb9188cdab672d5cc6f8632a3c64b837a29ebdd Mon Sep 17 00:00:00 2001 From: Thomas Wolf Date: Wed, 21 Jul 2021 19:53:47 +0200 Subject: [PATCH] [sshd] Minor code clean-up Since upstream changed the method profile to throw Exception it's not necessary anymore to re-throw as IOException. Change-Id: I31afab4f6e1a2f0feef79e6abced20d0ca1c493b --- .../transport/sshd/JGitClientSession.java | 52 +++++++------------ 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java index 2133a29cc..f7b37d781 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java @@ -16,7 +16,6 @@ import java.io.StreamCorruptedException; import java.net.SocketAddress; import java.nio.charset.StandardCharsets; -import java.security.GeneralSecurityException; import java.security.PublicKey; import java.util.ArrayList; import java.util.Collection; @@ -46,10 +45,10 @@ import org.apache.sshd.common.kex.KexProposalOption; import org.apache.sshd.common.kex.KeyExchangeFactory; import org.apache.sshd.common.kex.extension.KexExtensionHandler; +import org.apache.sshd.common.kex.extension.KexExtensionHandler.AvailabilityPhase; import org.apache.sshd.common.kex.extension.KexExtensions; import org.apache.sshd.common.keyprovider.KeyPairProvider; import org.apache.sshd.common.signature.BuiltinSignatures; -import org.apache.sshd.common.kex.extension.KexExtensionHandler.AvailabilityPhase; import org.apache.sshd.common.util.Readable; import org.apache.sshd.common.util.buffer.Buffer; import org.eclipse.jgit.errors.InvalidPatternException; @@ -152,23 +151,16 @@ protected IoWriteFuture sendIdentification(String ident, List extraLines) throws Exception { StatefulProxyConnector proxy = proxyHandler; if (proxy != null) { - try { - // We must not block here; the framework starts reading messages - // from the peer only once the initial sendKexInit() following - // this call to sendIdentification() has returned! - proxy.runWhenDone(() -> { - JGitClientSession.super.sendIdentification(ident, - extraLines); - return null; - }); - // Called only from the ClientSessionImpl constructor, where the - // return value is ignored. + // We must not block here; the framework starts reading messages + // from the peer only once the initial sendKexInit() following + // this call to sendIdentification() has returned! + proxy.runWhenDone(() -> { + JGitClientSession.super.sendIdentification(ident, extraLines); return null; - } catch (IOException e) { - throw e; - } catch (Exception other) { - throw new IOException(other.getLocalizedMessage(), other); - } + }); + // Called only from the ClientSessionImpl constructor, where the + // return value is ignored. + return null; } return super.sendIdentification(ident, extraLines); } @@ -177,22 +169,16 @@ protected IoWriteFuture sendIdentification(String ident, protected byte[] sendKexInit() throws Exception { StatefulProxyConnector proxy = proxyHandler; if (proxy != null) { - try { - // We must not block here; the framework starts reading messages - // from the peer only once the initial sendKexInit() has - // returned! - proxy.runWhenDone(() -> { - JGitClientSession.super.sendKexInit(); - return null; - }); - // This is called only from the ClientSessionImpl - // constructor, where the return value is ignored. + // We must not block here; the framework starts reading messages + // from the peer only once the initial sendKexInit() has + // returned! + proxy.runWhenDone(() -> { + JGitClientSession.super.sendKexInit(); return null; - } catch (IOException | GeneralSecurityException e) { - throw e; - } catch (Exception other) { - throw new IOException(other.getLocalizedMessage(), other); - } + }); + // This is called only from the ClientSessionImpl + // constructor, where the return value is ignored. + return null; } return super.sendKexInit(); }