All Implemented Interfaces:
Closeable, AutoCloseable

class TimeoutPipedInputStreamextends PipedInputStream
Adds setReadTimeout(int). Must be used with a TimeoutPipedOutputStream.

To support InternalSocket.setSoTimeout(int). Package private, not a part of the public API, not for general use.

  • Field Details

    • timeout

      private int timeout
      Milliseconds a read waits for data.
    • _closedByWriter

      private boolean _closedByWriter
      True once the writing end has closed.
    • _closedByReader

      private volatile boolean _closedByReader
      True once the reading end has closed.
  • Constructor Details

    • TimeoutPipedInputStream

      public TimeoutPipedInputStream(int pipeSize)
      Creates the pipe with the requested buffer size.
      Parameters:
      pipeSize - the pipe buffer size in bytes, as passed to the superclass
  • Method Details

    • read

      public int read() throws IOException
      Read the next byte, blocking until available or the timeout is reached.
      Overrides:
      read in class PipedInputStream
      Throws:
      SocketTimeoutException - if timeout is reached
      IOException
    • setReadTimeout

      public void setReadTimeout(int ms)
      Must be called before blocking read call.
      Parameters:
      ms - less than or equal to zero means forever
    • x_receivedLast

      void x_receivedLast()
      To save state. We have to do this because can't get to closedByWriter in super.
    • close

      public void close() throws IOException
      Overridden to save state. We have to do this because can't get to closedByReader in super.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class PipedInputStream
      Throws:
      IOException