Class CountedErrorHandler

java.lang.Object
org.agrona.concurrent.CountedErrorHandler
All Implemented Interfaces:
AutoCloseable, ErrorHandler

public class CountedErrorHandler extends Object implements ErrorHandler, AutoCloseable
An ErrorHandler which calls AtomicCounter.increment() before delegating the exception.
  • Field Details

    • errorHandler

      private final ErrorHandler errorHandler
    • errorCounter

      private final AtomicCounter errorCounter
    • isClosed

      private volatile boolean isClosed
  • Constructor Details

    • CountedErrorHandler

      public CountedErrorHandler(ErrorHandler errorHandler, AtomicCounter errorCounter)
      Construct a counted error handler with a delegate and counter.
      Parameters:
      errorHandler - to delegate to.
      errorCounter - to increment before delegation.
  • Method Details

    • close

      public void close()
      Close so that onError(Throwable) will not delegate and instead print to System.err
      Specified by:
      close in interface AutoCloseable
    • isClosed

      public boolean isClosed()
      Has this instance been closed.
      Returns:
      true if close() has previously been called, otherwise false.
    • onError

      public void onError(Throwable throwable)
      Callback to notify of an error that has occurred when processing an operation or event.

      This method is assumed non-throwing, so rethrowing the exception or triggering further exceptions would be a bug.

      Specified by:
      onError in interface ErrorHandler
      Parameters:
      throwable - that occurred while processing an operation or event.