Skip to content

FutureReturnValueIgnored analogue for CompletionStages #983

@ninepints

Description

@ninepints

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

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

Error Prone compiles this with no complaints. However, if the type of c is changed to CompletableFuture<Void>, 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions