Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8260680

PipedOutputStream.write in a JShell throws error "pipe closed"

XMLWordPrintable

      The reproducer starts two threads, 1 for initialising Input/OutputStreams, the second which sets up a JavaShellToolBuilder which accepts these Streams as parameters.

      The reason for "Pipe closed" is as follows:

      This issue is seen when upgrading from jdk11.0.8 to jdk11.0.9. A major JLine upgrade went into this version (3.9.0) (https://bugs.openjdk.java.net/browse/JDK-8246176)

      The bug seems to have been introduced in this upgraded source code, more specifically in the LineReaderImpl::readLine

      Here is a snippet from lines 637-640:

      Binding o = readBinding(getKeys(), local);
      if (o == null) {
      throw new EndOfFileException();
      }

      It appears when the program runs, this EndOfFileException is always thrown. When going deeper into the readBinding method, there is the BindingReader::readBinding method which makes a call to readCharacter(). This appears to always return a -1 (EOF) in the case of this reproducer and throws the Exception.

      The reason this has not been caught earlier is because of https://bugs.openjdk.java.net/browse/JDK-8215438 “CTRL+D causes EOF”

       While this fix does indeed stop the CTRL+D error, by catching this error silently, it is allowing the JShell to exit quietly when an EOF is incorrectly caused by something else.



            ewhelan Evan Whelan (Inactive)
            shadowbug Shadow Bug
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: