Skip to content

Commit

Permalink
fix: prevent ConcurrentModificationException in CancellationSupport.c…
Browse files Browse the repository at this point in the history
…ancel

Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon committed Aug 24, 2023
1 parent e38cc1d commit 4ce614d
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
******************************************************************************/
package com.redhat.devtools.intellij.lsp4ij.internal;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;

import org.eclipse.lsp4j.jsonrpc.CancelChecker;

Expand All @@ -32,7 +32,7 @@ public class CancellationSupport implements CancelChecker {
private boolean cancelled;

public CancellationSupport() {
this.futuresToCancel = new ArrayList<CompletableFuture<?>>();
this.futuresToCancel = new CopyOnWriteArrayList<>();
this.cancelled = false;
}

Expand All @@ -45,7 +45,7 @@ public <T> CompletableFuture<T> execute(CompletableFuture<T> future) {
* Cancel all LSP requests.
*/
public void cancel() {
if (cancelled == true) {
if (cancelled) {
return;
}
this.cancelled = true;
Expand Down

0 comments on commit 4ce614d

Please sign in to comment.