Class SafeResponseConsumer<T>

java.lang.Object
co.elastic.clients.transport.rest_client.SafeResponseConsumer<T>
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.concurrent.Cancellable, org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T>

public class SafeResponseConsumer<T> extends Object implements org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T>
A response consumer that will propagate Errors as RuntimeExceptions to avoid crashing the IOReactor.
  • Field Details

    • DEFAULT_FACTORY

      public static final org.elasticsearch.client.HttpAsyncResponseConsumerFactory DEFAULT_FACTORY
      A consumer factory that safely wraps the one provided by RequestOptions.DEFAULT.
    • DEFAULT_REQUEST_OPTIONS

      public static final org.elasticsearch.client.RequestOptions DEFAULT_REQUEST_OPTIONS
      Same as RequestOptions.DEFAULT with a safe consumer factory
  • Constructor Details

    • SafeResponseConsumer

      public SafeResponseConsumer(org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T> delegate)
  • Method Details

    • responseReceived

      public void responseReceived(org.apache.http.HttpResponse response) throws IOException, org.apache.http.HttpException
      Specified by:
      responseReceived in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T>
      Throws:
      IOException
      org.apache.http.HttpException
    • consumeContent

      public void consumeContent(org.apache.http.nio.ContentDecoder decoder, org.apache.http.nio.IOControl ioControl) throws IOException
      Specified by:
      consumeContent in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T>
      Throws:
      IOException
    • responseCompleted

      public void responseCompleted(org.apache.http.protocol.HttpContext context)
      Specified by:
      responseCompleted in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T>
    • failed

      public void failed(Exception ex)
      Specified by:
      failed in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T>
    • getException

      public Exception getException()
      Specified by:
      getException in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T>
    • getResult

      public T getResult()
      Specified by:
      getResult in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T>
    • isDone

      public boolean isDone()
      Specified by:
      isDone in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T>
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • cancel

      public boolean cancel()
      Specified by:
      cancel in interface org.apache.http.concurrent.Cancellable