Interface ServerResponse.AsyncBuilder<B extends ServerResponse.AsyncBuilder<B>>

Type Parameters:
B - the builder subclass
All Known Subinterfaces:
ServerResponse.SseBuilder, ServerResponse.StreamBuilder
Enclosing interface:
ServerResponse

public static interface ServerResponse.AsyncBuilder<B extends ServerResponse.AsyncBuilder<B>>
Defines a builder for async response bodies.
Since:
6.2
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Completes the stream.
    void
    Completes the stream with the given error.
    onComplete(Runnable onCompletion)
    Register a callback to be invoked when the request completes.
    Register a callback to be invoked when an error occurs during processing.
    onTimeout(Runnable onTimeout)
    Register a callback to be invoked when a request times out.
  • Method Details

    • error

      void error(Throwable t)
      Completes the stream with the given error.

      The throwable is dispatched back into Spring MVC, and passed to its exception handling mechanism. Since the response has been committed by this point, the response status can not change.

      Parameters:
      t - the throwable to dispatch
    • complete

      void complete()
      Completes the stream.
    • onTimeout

      B onTimeout(Runnable onTimeout)
      Register a callback to be invoked when a request times out.
      Parameters:
      onTimeout - the callback to invoke on timeout
      Returns:
      this builder
    • onError

      B onError(Consumer<Throwable> onError)
      Register a callback to be invoked when an error occurs during processing.
      Parameters:
      onError - the callback to invoke on error
      Returns:
      this builder
    • onComplete

      B onComplete(Runnable onCompletion)
      Register a callback to be invoked when the request completes.
      Parameters:
      onCompletion - the callback to invoked on completion
      Returns:
      this builder