Class NGOutputStream

All Implemented Interfaces:
Closeable, DataOutput, Flushable, AutoCloseable

class NGOutputStream extends DataOutputStream
Wraps an OutputStream to send writes in NailGun chunks. Because multiple NGOutputStreams wrap the same OutputStream (that is, the OutputStream obtained from the Socket connection with the client), writes are synchronized on the underlying OutputStream. If this were not the case, write interleaving could completely break the NailGun protocol.
  • Field Details

    • lock

      private final Object lock
    • streamCode

      private byte streamCode
  • Constructor Details

    • NGOutputStream

      public NGOutputStream(OutputStream out, byte streamCode)
      Creates a new NGOutputStream wrapping the specified OutputStream and using the specified Nailgun chunk code.
      Parameters:
      out - the OutputStream to wrap
      streamCode - the NailGun chunk code associated with this stream (i.e., '1' for stdout, '2' for stderr).
  • Method Details