Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tweaked CompletionHandler to use a stateless enum variant

  • Loading branch information...
commit 3a06e62cadcf92cf314e896e6403e17546e3bd02 1 parent 3e683e1
@jbrisbin jbrisbin authored
View
12 async-api-tests/src/test/java/org/springframework/async/PromiseTests.java
@@ -12,9 +12,11 @@
@SuppressWarnings({"unchecked"})
public class PromiseTests {
- private final Logger log = LoggerFactory.getLogger(getClass());
+ private static final Logger log = LoggerFactory.getLogger(PromiseTests.class);
+
+ private static enum Handler implements CompletionHandler<String, CountDownLatch> {
+ INSTANCE;
- private CompletionHandler<String, CountDownLatch> handler = new CompletionHandler<String, CountDownLatch>() {
@Override public void completed(String result, CountDownLatch latch) {
log.info("Got result: " + result + " with attachment: " + latch);
latch.countDown();
@@ -24,15 +26,15 @@
log.error(t.getMessage(), t);
latch.countDown();
}
+ }
- };
@Test
public void testPromiseCompletionHandler() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
LongRunningAction action = new LongRunningAction();
- action.executeLongRunningAction(latch).complete(handler);
+ action.executeLongRunningAction(latch).complete(Handler.INSTANCE);
latch.await();
}
@@ -42,7 +44,7 @@ public void testPromiseFailure() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
LongRunningAction action = new LongRunningAction();
- action.executeFailedAction(latch).complete(handler);
+ action.executeFailedAction(latch).complete(Handler.INSTANCE);
latch.await();
}
Please sign in to comment.
Something went wrong with that request. Please try again.