use of com.lmax.disruptor.ExceptionHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportSpecifyingADefaultExceptionHandlerForEventProcessors.
@Test
public void shouldSupportSpecifyingADefaultExceptionHandlerForEventProcessors() throws Exception {
AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>();
ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled);
RuntimeException testException = new RuntimeException();
ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException);
disruptor.setDefaultExceptionHandler(exceptionHandler);
disruptor.handleEventsWith(handler);
publishEvent();
final Throwable actualException = waitFor(eventHandled);
assertSame(testException, actualException);
}
use of com.lmax.disruptor.ExceptionHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportSpecifyingAExceptionHandlerForEventProcessors.
@Test
public void shouldSupportSpecifyingAExceptionHandlerForEventProcessors() throws Exception {
AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>();
ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled);
RuntimeException testException = new RuntimeException();
ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException);
disruptor.handleExceptionsWith(exceptionHandler);
disruptor.handleEventsWith(handler);
publishEvent();
final Throwable actualException = waitFor(eventHandled);
assertSame(testException, actualException);
}
use of com.lmax.disruptor.ExceptionHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldApplyDefaultExceptionHandlerToExistingEventProcessors.
@Test
public void shouldApplyDefaultExceptionHandlerToExistingEventProcessors() throws Exception {
AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>();
ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled);
RuntimeException testException = new RuntimeException();
ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException);
disruptor.handleEventsWith(handler);
disruptor.setDefaultExceptionHandler(exceptionHandler);
publishEvent();
final Throwable actualException = waitFor(eventHandled);
assertSame(testException, actualException);
}
use of com.lmax.disruptor.ExceptionHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldOnlyApplyExceptionsHandlersSpecifiedViaHandleExceptionsWithOnNewEventProcessors.
@Test
public void shouldOnlyApplyExceptionsHandlersSpecifiedViaHandleExceptionsWithOnNewEventProcessors() throws Exception {
AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>();
ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled);
RuntimeException testException = new RuntimeException();
ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException);
disruptor.handleExceptionsWith(exceptionHandler);
disruptor.handleEventsWith(handler);
disruptor.handleExceptionsWith(new FatalExceptionHandler());
publishEvent();
final Throwable actualException = waitFor(eventHandled);
assertSame(testException, actualException);
}
Aggregations