Skip to content

Commit

Permalink
Don't call System.exit on exit, might cause workspace corruption
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <fbricon@gmail.com>
  • Loading branch information
fbricon committed Mar 28, 2017
1 parent 326f6c6 commit 86fd7a6
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.ls.core.internal.JavaClientConnection;
Expand Down Expand Up @@ -67,7 +69,10 @@
*
*/
public class JDTLanguageServer implements LanguageServer, TextDocumentService, WorkspaceService, JavaProtocolExtensions {

/**
* Exit code returned when JDTLanguageServer is forced to exit.
*/
private static final int FORCED_EXIT_CODE = 1;
private JavaClientConnection client;
private ProjectsManager pm;
private LanguageServerWorkingCopyOwner workingCopyOwner;
Expand Down Expand Up @@ -115,7 +120,10 @@ public CompletableFuture<Object> shutdown() {
@Override
public void exit() {
logInfo(">> exit");
System.exit(0);
Executors.newSingleThreadScheduledExecutor().schedule(() -> {
logInfo("Forcing exit after 1 min.");
System.exit(FORCED_EXIT_CODE);
}, 1, TimeUnit.MINUTES);
}

/* (non-Javadoc)
Expand Down

0 comments on commit 86fd7a6

Please sign in to comment.