vert.x
vert.x copied to clipboard
NullPointerException in Future.await
How to reproduce: interrupt the waiting thread in the middle of CountDownLatch.await
try {
cont.suspendAndAwaitResume();
} catch (InterruptedException e) {
Utils.throwAsUnchecked(e.getCause());
return null;
}
InterruptedException.cause is null.
throw null produces NPE.
PS:
Utils.throwAsUnchecked(e.getCause());
return null;
can also be optimized into one line
public static <E extends Throwable> **RuntimeException** throwAsUnchecked(Throwable t) throws E {
throw (E) t;
}
after it, use:
throw Utils.throwAsUnchecked(e);
PPS: and "happy path" for aready competed Futures
default T await() {
if (isComplete()) {
return ...
}
PR: https://github.com/eclipse-vertx/vert.x/pull/4958