ListenableFuture<String> future = executor.submit(() -> "foo");
- assertEquals( "Future result", "foo", future.get( 5, TimeUnit.SECONDS));
+ assertEquals("Future result", "foo", future.get(5, TimeUnit.SECONDS));
// Test submit with Runnable.
- executor.submit(() -> {
- }).get();
+ executor.submit(() -> { }).get();
// Test submit with Runnable and value.
}
@Test
+ @SuppressWarnings("checkstyle:illegalThrows")
public void testNonBlockingSubmitOnExecutorThread() throws Throwable {
executor = newExecutor();
testNonBlockingSubmitOnExecutorThread(EXECUTE, SUBMIT_CALLABLE);
}
+ @SuppressWarnings("checkstyle:illegalThrows")
void testNonBlockingSubmitOnExecutorThread(final InitialInvoker initialInvoker, final Invoker invoker)
throws Throwable {
}
@Override
+ @SuppressWarnings("checkstyle:parameterName")
public void onFailure(@Nonnull final Throwable t) {
caughtEx.set(t);
futureCompletedLatch.countDown();
}
@Test
- public void testBlockingSubmitOnExecutorThread() throws Exception {
+ public void testBlockingSubmitOnExecutorThread() throws InterruptedException {
executor = newExecutor();
testBlockingSubmitOnExecutorThread(EXECUTE, SUBMIT_CALLABLE);
}
+ @SuppressWarnings("checkstyle:illegalCatch")
void testBlockingSubmitOnExecutorThread(final InitialInvoker initialInvoker, final Invoker invoker)
- throws Exception {
+ throws InterruptedException {
final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
try {
invoker.invokeExecutor(executor, null).get();
- } catch(ExecutionException e) {
+ } catch (ExecutionException e) {
caughtEx.set(e.getCause());
- } catch(Throwable e) {
+ } catch (Throwable e) {
caughtEx.set(e);
} finally {
latch.countDown();
initialInvoker.invokeExecutor(executor, task);
- assertTrue("Task did not complete - executor likely deadlocked", latch.await( 5, TimeUnit.SECONDS));
+ assertTrue("Task did not complete - executor likely deadlocked", latch.await(5, TimeUnit.SECONDS));
assertNotNull("Expected exception thrown", caughtEx.get());
assertEquals("Caught exception type", TestDeadlockException.class, caughtEx.get().getClass());
}