Aller au contenu

Async Naming Suffix (ARCH4026)

Ce contenu n’est pas encore disponible dans votre langue.

Key java.async.async-method-suffix · Severity info · Category async

Methods returning a CompletableFuture should be named per the language idiom (e.g. an Async suffix) so callers see at the call site that the result must be awaited.

public CompletableFuture<User> load(long id) { // no suffix
return repository.findById(id);
}
public CompletableFuture<User> loadAsync(long id) {
return repository.findById(id);
}

Add an Async suffix to methods returning a CompletableFuture so the asynchronous contract is visible at the call site.