Class ErrorHandler.ErrorRequest

All Implemented Interfaces:
Content.Source, Request, Attributes
Enclosing class:
ErrorHandler

public static class ErrorHandler.ErrorRequest extends Request.AttributesWrapper
  • Constructor Details

  • Method Details

    • read

      public Content.Chunk read()
      Description copied from interface: Request

      Reads a chunk of content.

      See how to use this method idiomatically.

      The returned chunk could be:

      • null, to signal that there isn't a chunk of content available
      • an Content.Chunk instance with non null Content.Chunk.getFailure(), to signal that there was a failure trying to produce a chunk of content, or that the content production has been failed externally
      • a Content.Chunk instance, containing the chunk of content.

      Once a read returns an Content.Chunk instance with non-null Content.Chunk.getFailure() then if the failure is last further reads will continue to return the same failure chunk instance, otherwise further read() operations may return different non-failure chunks.

      Once a read returns a last chunk, further reads will continue to return a last chunk (although the instance may be different).

      The content reader code must ultimately arrange for a call to Retainable.release() on the returned Content.Chunk.

      Additionally, prior to the ultimate call to Retainable.release(), the reader code may make additional calls to Retainable.retain(), that must ultimately be matched by a correspondent number of calls to Retainable.release().

      Concurrent reads from different threads are not recommended, as they are inherently in a race condition.

      Reads performed outside the invocation context of a demand callback are allowed. However, reads performed with a pending demand are inherently in a race condition (the thread that reads with the thread that invokes the demand callback).

      In addition, the returned Content.Chunk may be a Trailers instance, in case of request content trailers.

      Specified by:
      read in interface Content.Source
      Specified by:
      read in interface Request
      Overrides:
      read in class Request.Wrapper
      Returns:
      a chunk of content, possibly a failure instance, or null
      See Also:
    • demand

      public void demand(Runnable demandCallback)
      Description copied from interface: Request

      Demands to invoke the given demand callback parameter when a chunk of content is available.

      See how to use this method idiomatically.

      Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the Runnable callback and a call to this method. Invocations of the passed Runnable are serialized and a callback for demand call is not invoked until any previous demand callback has returned. Thus the Runnable should not block waiting for a callback of a future demand call.

      The demand callback may be invoked spuriously: a subsequent call to Content.Source.read() may return null.

      Calling this method establishes a pending demand, which is fulfilled when the demand callback is invoked.

      Calling this method when there is already a pending demand results in an IllegalStateException to be thrown.

      If the invocation of the demand callback throws an exception, then Content.Source.fail(Throwable) is called.

      Specified by:
      demand in interface Content.Source
      Specified by:
      demand in interface Request
      Overrides:
      demand in class Request.Wrapper
      Parameters:
      demandCallback - the demand callback to invoke when there is a content chunk available.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Request.Wrapper