diff --git a/api/src/main/java/jakarta/enterprise/concurrent/Async.java b/api/src/main/java/jakarta/enterprise/concurrent/Async.java index 692e80b0..050c082b 100644 --- a/api/src/main/java/jakarta/enterprise/concurrent/Async.java +++ b/api/src/main/java/jakarta/enterprise/concurrent/Async.java @@ -233,7 +233,7 @@ * @since 3.0 */ public static class Result { - private static final ThreadLocal> futures = new ThreadLocal>(); + private static final ThreadLocal> FUTURES = new ThreadLocal>(); /** * Completes the {@link java.util.concurrent.CompletableFuture CompletableFuture} @@ -248,11 +248,12 @@ public static class Result { * @throws IllegalStateException if the CompletableFuture for an asynchronous * method is not present on the thread. */ - public static CompletableFuture complete(T result) { + public static CompletableFuture complete(final T result) { @SuppressWarnings("unchecked") - CompletableFuture future = (CompletableFuture) futures.get(); - if (future == null) + CompletableFuture future = (CompletableFuture) FUTURES.get(); + if (future == null) { throw new IllegalStateException(); + } future.complete(result); return future; } @@ -271,9 +272,10 @@ public static CompletableFuture complete(T result) { */ public static CompletableFuture getFuture() { @SuppressWarnings("unchecked") - CompletableFuture future = (CompletableFuture) futures.get(); - if (future == null) + CompletableFuture future = (CompletableFuture) FUTURES.get(); + if (future == null) { throw new IllegalStateException(); + } return future; } @@ -293,11 +295,12 @@ public static CompletableFuture getFuture() { * @param future CompletableFuture that the container returns to the caller, * or null to clear it. */ - public static void setFuture(CompletableFuture future) { - if (future == null) - futures.remove(); - else - futures.set(future); + public static void setFuture(final CompletableFuture future) { + if (future == null) { + FUTURES.remove(); + } else { + FUTURES.set(future); + } } } -} \ No newline at end of file +}