eclipse-vertx / eclipse-vertx/vert.x

NullPointerException in Future.await

Open
#4,972 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
14.7k
Forks
2.1k
Avg merge
2d 7h
Merged PRs (30d)
28

Description

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 **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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.