eclipse-vertx / eclipse-vertx/vert.x
NullPointerException in Future.await
- 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
Assessment
This issue has not been assessed yet.