You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The purpose of this method is to run some heavy code of publish data on a separate thread pool
// as that is blocking code. Whereas once published switch back to application thread pool.
// The response needs to be a CompletableFuture<Void> that informs if publish has successfully
// happened.
@SuppressWarnings("NullAway")
public CompletableFuture<Void> produceAsync(
@Nonnull Parameter1, @Nonnull Parameter2) {
return CompletableFuture.supplyAsync(
() -> {
// Some method that will publish data, also might throw an error as RuntimeException
return null;
},
someExecutorService)
// If an exception occurs or not we move the flow to application thread pool.
.handleAsync(
(ignored, throwable) -> {
if (throwable != null) {
if (throwable instanceof RuntimeException) {
throw (RuntimeException) throwable;
}
throw new RuntimeException(throwable);
}
// In case there was no exception return null.
// NullAway is complaining we are returning null. Hence using suppress warning annotation.
// The null is converted to CompletableFuture<Object> and then to CompletbaleFuture<Void>.
return null;
},
applicationExecutorService)
// Convert to Void completable future. whenCompleteAsync returns Object completable future.
.thenRun(() -> {});
}
}
Linter complaining about null when contract of method is @nonnull. However, the null is converted from CompletableFuture -> CompletableFuture
We might need to fix the edge case for the linter. In general I think, NullAway for the special case of T is unable to handle it.
The text was updated successfully, but these errors were encountered:
Sorry, I can't understand what error you are seeing. Can you point out the exact location where the error is reported and what the error message is? And also can you fix the formatting of your example code? Thanks!
Linter complaining about null when contract of method is @nonnull. However, the null is converted from CompletableFuture -> CompletableFuture
We might need to fix the edge case for the linter. In general I think, NullAway for the special case of T is unable to handle it.
The text was updated successfully, but these errors were encountered: