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:34 UTC

[mina-sshd] 01/02: [SSHD-1064] Using ByteArrayOutputStream#toString(Charset) to retrieve STDERR error message in ClientSession#executeRemoteCommand

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));
             }