[ 
https://issues.apache.org/jira/browse/SSHD-1303?focusedWorklogId=818962&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-818962
 ]

ASF GitHub Bot logged work on SSHD-1303:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Oct/22 23:41
            Start Date: 20/Oct/22 23:41
    Worklog Time Spent: 10m 
      Work Description: lgoldstein commented on code in PR #255:
URL: https://github.com/apache/mina-sshd/pull/255#discussion_r1001218334


##########
sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java:
##########
@@ -474,4 +494,48 @@ public Integer getExitStatus() {
     public String getExitSignal() {
         return exitSignalHolder.get();
     }
+
+    private enum NullIoInputStream implements IoInputStream {

Review Comment:
   Recommend making this a *public*  class in same package as `IoInputStream` 
or a member of it. Might come useful in the future.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 818962)
    Time Spent: 20m  (was: 10m)

> Keeping error streams and input streams separate after 
> ChannelExec#setRedirectErrorStream(true) is called
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: SSHD-1303
>                 URL: https://issues.apache.org/jira/browse/SSHD-1303
>             Project: MINA SSHD
>          Issue Type: Improvement
>    Affects Versions: 2.9.1
>         Environment: Java 8
>            Reporter: dgü
>            Assignee: Thomas Wolf
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Hello!
> As I understand, if I call {_}ChannelExec#setRedirectErrorStream(true){_}, 
> then _ChannelExec#getInvertedErr()_ and _ChannelExec#getInvertedOut()_ return 
> the same input stream.
> If I redirect error stream and read the error stream before the input stream, 
> then the error stream returns the message even if there is an error or not, 
> which is not expected.
> Here is the test case
> {code:java}
>             BufferedReader input;
>             String line;
>             
>             //process.getErrorStream() gets its value from 
> ChannelExec#getInvertedErr()
>             System.out.println("getErrorStream: " + process.getErrorStream());
>             input = new BufferedReader(new 
> InputStreamReader(process.getErrorStream()));
>             while ((line = input.readLine()) != null) {
>                 System.out.println(line);
>             }
>             //process.getInputStream() gets its value from 
> ChannelExec#getInvertedOut()
>             System.out.println("getInputStream: " + process.getInputStream());
>             input = new BufferedReader(new 
> InputStreamReader(process.getInputStream()));
>             while ((line = input.readLine()) != null) {
>                 System.out.println(line);
>             }
> {code}
> Here is an output excerpt:
> {quote}getErrorStream: 
> org.apache.sshd.common.channel.ChannelPipedInputStream@bd8db5a
> total 0
> drwx------. 3 root root 17 Oct 17 10:31 
> systemd-private-c3ce924f90c24e4a86f637831f434fe3-chronyd.service-DwM2fR
> drwx------. 3 root root 17 Oct 14 13:22 
> systemd-private-e0701fd845894b6087a236a976c00b35-chronyd.service-2z3OOv
> getInputStream: org.apache.sshd.common.channel.ChannelPipedInputStream@bd8db5a
> Exception in thread "main" java.io.IOException: Pipe closed after 0 cycles
> at 
> org.apache.sshd.common.channel.ChannelPipedInputStream.read(ChannelPipedInputStream.java:126)
> at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
> at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
> at java.io.InputStreamReader.read(InputStreamReader.java:184)
> at java.io.BufferedReader.fill(BufferedReader.java:161)
> at java.io.BufferedReader.readLine(BufferedReader.java:324)
> at java.io.BufferedReader.readLine(BufferedReader.java:389)
> {quote}
> As seen above, _ls_ command output comes from the error stream even if the 
> error redirection is set to _true_ and command runs {_}successfully{_}.
> The second problem is an exception problem. It is independent from the error 
> stream redirection. I have openned SSHD-1302 for this.
> Requests:
>  - Is it possible to make ChannelExec#getInvertedErr() and 
> ChannelExec#getInvertedOut() two separate input streams ?
>  - Is it possible to rely on java.lang.ProcessBuilder, so that the stream 
> returned from error stream will always be a _null input stream_ as below from 
> Java 8 source code:
> static class NullInputStream extends InputStream {
> static final NullInputStream INSTANCE = new NullInputStream();
> private NullInputStream() {}
> public int read() \{ return -1; }
> public int available()
> { return 0; }
> }
> Thanks in advance...



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org

Reply via email to