Package org.agrona.concurrent
Class CountedErrorHandler
- java.lang.Object
-
- org.agrona.concurrent.CountedErrorHandler
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,ErrorHandler
public class CountedErrorHandler extends java.lang.Object implements ErrorHandler, java.lang.AutoCloseable
AnErrorHandler
which callsAtomicCounter.increment()
before delegating the exception.
-
-
Field Summary
Fields Modifier and Type Field Description private AtomicCounter
errorCounter
private ErrorHandler
errorHandler
private boolean
isClosed
-
Constructor Summary
Constructors Constructor Description CountedErrorHandler(ErrorHandler errorHandler, AtomicCounter errorCounter)
Construct a counted error handler with a delegate and counter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close so thatonError(Throwable)
will not delegate and instead print toSystem.err
.boolean
isClosed()
Has this instance been closed.void
onError(java.lang.Throwable throwable)
Callback to notify of an error that has occurred when processing an operation or event.
-
-
-
Field Detail
-
errorHandler
private final ErrorHandler errorHandler
-
errorCounter
private final AtomicCounter errorCounter
-
isClosed
private volatile boolean isClosed
-
-
Constructor Detail
-
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 Detail
-
close
public void close()
Close so thatonError(Throwable)
will not delegate and instead print toSystem.err
.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
isClosed
public boolean isClosed()
Has this instance been closed.- Returns:
- true if
close()
has previously been called, otherwise false.
-
onError
public void onError(java.lang.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 interfaceErrorHandler
- Parameters:
throwable
- that occurred while processing an operation or event.
-
-