use of com.hazelcast.util.FutureUtil.ExceptionHandler in project hazelcast by hazelcast.
the class FutureUtilTest method testTransactionTimedOutExceptionHandler.
@Test(expected = TransactionTimedOutException.class)
public void testTransactionTimedOutExceptionHandler() throws Exception {
final ExceptionHandler exceptionHandler = FutureUtil.RETHROW_TRANSACTION_EXCEPTION;
final Throwable throwable = new TimeoutException();
exceptionHandler.handleException(throwable);
}
use of com.hazelcast.util.FutureUtil.ExceptionHandler in project hazelcast by hazelcast.
the class FutureUtilTest method test_returnWithDeadline_timeout_exception.
@Test(expected = TimeoutException.class)
public void test_returnWithDeadline_timeout_exception() throws Exception {
AtomicBoolean waitLock = new AtomicBoolean(true);
ExecutorService executorService = Executors.newFixedThreadPool(2);
List<Future<Integer>> futures = new ArrayList<Future<Integer>>();
for (int i = 0; i < 2; i++) {
Future<Integer> submit = (Future<Integer>) executorService.submit(new TimeoutingTask(waitLock));
futures.add(submit);
}
returnWithDeadline(futures, 1, TimeUnit.SECONDS, new ExceptionHandler() {
@Override
public void handleException(Throwable throwable) {
if (throwable instanceof TimeoutException) {
ExceptionUtil.sneakyThrow(throwable);
}
throw ExceptionUtil.rethrow(throwable);
}
});
}
Aggregations