You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2020/08/28 07:47:33 UTC
[mina-sshd] branch master updated (61785ae -> 8415ed4)
This is an automated email from the ASF dual-hosted git repository.
lgoldstein pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git.
from 61785ae [SSHD-1059] Do not send heartbeat if KEX state not DONE
new 6257ffa [SSHD-1064] Using ByteArrayOutputStream#toString(Charset) to retrieve STDERR error message in ClientSession#executeRemoteCommand
new 8415ed4 [SSHD-1064] Fixed ClientSession#executeRemoteCommand handling of STDERR in case of exception to behave according to its documentation
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
CHANGES.md | 1 +
.../org/apache/sshd/client/session/ClientSession.java | 15 ++++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)
[mina-sshd] 02/02: [SSHD-1064] Fixed
ClientSession#executeRemoteCommand handling of STDERR in case of exception
to behave according to its documentation
Posted by lg...@apache.org.
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
commit 8415ed4a86b6c64cfae36a0dcd77542d498caff4
Author: Lyor Goldstein <lg...@apache.org>
AuthorDate: Thu Aug 27 08:45:22 2020 +0300
[SSHD-1064] Fixed ClientSession#executeRemoteCommand handling of STDERR in case of exception to behave according to its documentation
---
CHANGES.md | 1 +
.../java/org/apache/sshd/client/session/ClientSession.java | 14 ++++++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 7470f94..bf19bdd 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -25,6 +25,7 @@ or `-key-file` command line option.
* [SSHD-1042](https://issues.apache.org/jira/browse/SSHD-1042) Added more callbacks to SftpEventListener
* [SSHD-1040](https://issues.apache.org/jira/browse/SSHD-1040) Make server key available after KEX completed.
* [SSHD-1060](https://issues.apache.org/jira/browse/SSHD-1060) Do not store logger level in fields.
+* [SSHD-1064](https://issues.apache.org/jira/browse/SSHD-1064) Fixed `ClientSession#executeRemoteCommand` handling of STDERR in case of exception to behave according to its documentation
## Behavioral changes and enhancements
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
index eb5b508..075d026 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
@@ -209,13 +209,15 @@ public interface ClientSession
*/
default String executeRemoteCommand(String command) throws IOException {
try (ByteArrayOutputStream stderr = new ByteArrayOutputStream()) {
- String response = executeRemoteCommand(command, stderr, StandardCharsets.US_ASCII);
- if (stderr.size() > 0) {
- String errorMessage = stderr.toString(StandardCharsets.US_ASCII.name());
- throw new RemoteException("Error reported from remote command='" + command, new ServerException(errorMessage));
+ try {
+ return executeRemoteCommand(command, stderr, StandardCharsets.US_ASCII);
+ } finally {
+ if (stderr.size() > 0) {
+ String errorMessage = stderr.toString(StandardCharsets.US_ASCII.name());
+ throw new RemoteException(
+ "Error reported from remote command=" + command, new ServerException(errorMessage));
+ }
}
-
- return response;
}
}
[mina-sshd] 01/02: [SSHD-1064] Using
ByteArrayOutputStream#toString(Charset) to retrieve STDERR error message in
ClientSession#executeRemoteCommand
Posted by lg...@apache.org.
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
commit 6257ffaddd65bdec524302d2f816a5629e446b73
Author: Lyor Goldstein <lg...@apache.org>
AuthorDate: Tue Aug 25 21:17:04 2020 +0300
[SSHD-1064] Using ByteArrayOutputStream#toString(Charset) to retrieve STDERR error message in ClientSession#executeRemoteCommand
---
.../src/main/java/org/apache/sshd/client/session/ClientSession.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
index 86a8ccb..eb5b508 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
@@ -211,8 +211,7 @@ public interface ClientSession
try (ByteArrayOutputStream stderr = new ByteArrayOutputStream()) {
String response = executeRemoteCommand(command, stderr, StandardCharsets.US_ASCII);
if (stderr.size() > 0) {
- byte[] error = stderr.toByteArray();
- String errorMessage = new String(error, StandardCharsets.US_ASCII);
+ String errorMessage = stderr.toString(StandardCharsets.US_ASCII.name());
throw new RemoteException("Error reported from remote command='" + command, new ServerException(errorMessage));
}