google / google/error-prone

FutureReturnValueIgnored analogue for CompletionStages

Open
#983 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

Hi! I have a proposal for a new check based on a situation that came up at work. Here is (essentially) our code:

```
CompletionStage c = CompletableFuture.completedFuture(null);
c.thenRun(() -> {...});
```

Error Prone compiles this with no complaints. However, if the type of `c` is changed to `CompletableFuture`, we get a warning about the return value of `thenRun` being ignored. FutureReturnValueIgnored kicks in because the return value is known to be a `CompletableFuture` rather than just a `CompletionStage`.

Since it seems equally dangerous to ignore a returned `CompletionStage` - exceptions thrown by the lambda above are suppressed - maybe Error Prone should warn about that too?

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.