Skip to content

Commit

Permalink
fix: prevent from NPE CancellationSupport
Browse files Browse the repository at this point in the history
Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Oct 14, 2024
1 parent e3f7ef4 commit 178db4d
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,15 @@ protected synchronized CompletableFuture<Result> load(Params params) {
* Cancel all LSP requests.
*/
public void cancel() {
// Store the CancellationSupport in a local variable to prevent from NPE (very rare case)
CancellationSupport cancellation = cancellationSupport;
var future = this.future;
if (future != null && !future.isCancelled() && !future.isDone()) {
future.cancel(true);
}
this.future = null;
// Store the CancellationSupport in a local variable to prevent from NPE (very rare case)
CancellationSupport cancellation = cancellationSupport;
if (cancellation != null) {
cancellation.cancel();
}
cancellationSupport = null;
}
}

0 comments on commit 178db4d

Please sign in to comment.