Uploaded image for project: 'MINA SSHD'
  1. MINA SSHD
  2. SSHD-1302

Reading again from exhausted ChannelExec#getInvertedOut() throws IOException instead of returning -1

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.9.1
    • 2.9.2
    • None
    • Java 8

    Description

      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:

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

      Here is an output excerpt:

      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)

      It looks the input stream is closed.

      is it possible not to throw an exception to rely on java.io.InputStream ?

      Thanks in advance...

      Attachments

        Activity

          People

            twolf Thomas Wolf
            dgun dgü
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m