-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…808) * Test exception in ConnectionStreamProvider.start() When ConnectionStreamProvider.start() throws an IOException, a race condition can occur that causes further attempts to start the language server to be ignored (issue 804) * Fix race condition in LanguageServerWrapper Fixes #804
- Loading branch information
1 parent
1349c72
commit 32fd663
Showing
4 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...lsp4e.test/src/org/eclipse/lsp4e/test/utils/MockConnectionProviderWithStartException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 Red Hat Inc. and others. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Lucia Jelinkova (Red Hat Inc.) - initial implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lsp4e.test.utils; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
public class MockConnectionProviderWithStartException extends MockConnectionProvider { | ||
private static volatile CompletableFuture<Void> startFuture = new CompletableFuture<>(); | ||
private static volatile int startCounter = 0; | ||
private static volatile int stopCounter = 0; | ||
public static void resetStartFuture() { | ||
startFuture = new CompletableFuture<>(); | ||
} | ||
|
||
public static void waitForStart() throws ExecutionException, InterruptedException, TimeoutException { | ||
startFuture.get(2, TimeUnit.SECONDS); | ||
} | ||
|
||
public static void resetCounters() { | ||
startCounter = 0; | ||
stopCounter = 0; | ||
} | ||
|
||
public static int getStartCounter() { | ||
return startCounter; | ||
} | ||
|
||
public static int getStopCounter() { | ||
return stopCounter; | ||
} | ||
|
||
@Override | ||
public void start() throws IOException { | ||
startCounter++; | ||
startFuture.complete(null); | ||
throw new IOException("Start failed"); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
stopCounter++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters