[jira] [Commented] (SSHD-1302) Handling empty ChannelExec#getInvertedOut() to rely on InputStream
[ https://issues.apache.org/jira/browse/SSHD-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17622470#comment-17622470 ] Thomas Wolf commented on SSHD-1302: --- Thanks for this report. IMO this is simply broken, and should be considered a bug. Fixed by [PR 256|https://github.com/apache/mina-sshd/pull/256]. > Handling empty ChannelExec#getInvertedOut() to rely on InputStream > -- > > Key: SSHD-1302 > URL: https://issues.apache.org/jira/browse/SSHD-1302 > Project: MINA SSHD > Issue Type: Improvement >Affects Versions: 2.9.1 > Environment: Java 8 >Reporter: dgü >Assignee: Thomas Wolf >Priority: Major > Time Spent: 10m > Remaining Estimate: 0h > > Hello! > If I read an input stream until end of it, and then read it again, it throws > an exception. > Here is the test case: > {code:java} > BufferedReader input; > String 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); > } > 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}getInputStream: > 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} > It looks the input stream is closed. > is it possible not to throw an exception to rely on java.io.InputStream ? > 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
[jira] [Commented] (SSHD-1302) Handling empty ChannelExec#getInvertedOut() to rely on InputStream
[ https://issues.apache.org/jira/browse/SSHD-1302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17618893#comment-17618893 ] dgü commented on SSHD-1302: --- If it is not possible not to close the stream, it is possible to document that when end of _ChannelExec#getInvertedOut()_ is reached, it is closed. > Handling empty ChannelExec#getInvertedOut() to rely on InputStream > -- > > Key: SSHD-1302 > URL: https://issues.apache.org/jira/browse/SSHD-1302 > Project: MINA SSHD > Issue Type: Improvement >Affects Versions: 2.9.1 > Environment: Java 8 >Reporter: dgü >Priority: Major > > Hello! > If I read an input stream until end of it, and then read it again, it throws > an exception. > Here is the test case: > {code:java} > BufferedReader input; > String 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); > } > 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}getInputStream: > 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} > It looks the input stream is closed. > is it possible not to throw an exception to rely on java.io.InputStream ? > 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