@@ -189,7 +189,6 @@ public static Pair<Boolean, String> sshExecute(String host, int port, String use
189189
190190 byte [] buffer = new byte [8192 ];
191191 StringBuffer sbResult = new StringBuffer ();
192-
193192 int currentReadBytes = 0 ;
194193 while (true ) {
195194 throwSshExceptionIfStdoutOrStdeerIsNull (stdout , stderr );
@@ -207,22 +206,18 @@ public static Pair<Boolean, String> sshExecute(String host, int port, String use
207206 if (canEndTheSshConnection (waitResultTimeoutInMs , sess , conditions )) {
208207 break ;
209208 }
210-
211209 }
212210
213- while (stdout .available () > 0 ) {
214- currentReadBytes = stdout .read (buffer );
215- sbResult .append (new String (buffer , 0 , currentReadBytes ));
211+ while ((currentReadBytes = stdout .read (buffer )) != -1 ) {
212+ sbResult .append (new String (buffer , 0 , currentReadBytes ));
216213 }
217214
218- while (stderr .available () > 0 ) {
219- currentReadBytes = stderr .read (buffer );
215+ while ((currentReadBytes = stderr .read (buffer )) != -1 ) {
220216 sbResult .append (new String (buffer , 0 , currentReadBytes ));
221217 }
222218 }
223219
224220 String result = sbResult .toString ();
225-
226221 if (StringUtils .isBlank (result )) {
227222 try {
228223 result = IOUtils .toString (stdout , StandardCharsets .UTF_8 );
@@ -243,7 +238,6 @@ public static Pair<Boolean, String> sshExecute(String host, int port, String use
243238 s_logger .error (String .format ("SSH execution of command %s has an error status code in return. Result output: %s" , command , result ));
244239 return new Pair <Boolean , String >(false , result );
245240 }
246-
247241 return new Pair <Boolean , String >(true , result );
248242 } finally {
249243 if (sess != null )
0 commit comments