Skip to content

Commit 0a81e65

Browse files
committed
Do not exit if client and server are the same process.
1 parent 9d93838 commit 0a81e65

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/LanguageServerApplication.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class LanguageServerApplication implements IApplication {
2323

2424
@Override
2525
public Object start(IApplicationContext context) throws Exception {
26-
2726
JavaLanguageServerPlugin.startLanguageServer(this);
2827
synchronized (waitLock) {
2928
while (!shutdown) {
@@ -61,7 +60,7 @@ public void setParentProcessId(long pid) {
6160
/**
6261
* @return the parentProcessId
6362
*/
64-
long getParentProcessId() {
63+
public long getParentProcessId() {
6564
return parentProcessId;
6665
}
6766
}

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/JDTLanguageServer.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.eclipse.jdt.ls.core.internal.JavaClientConnection.JavaLanguageClient;
4747
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
4848
import org.eclipse.jdt.ls.core.internal.JobHelpers;
49+
import org.eclipse.jdt.ls.core.internal.LanguageServerApplication;
4950
import org.eclipse.jdt.ls.core.internal.LanguageServerWorkingCopyOwner;
5051
import org.eclipse.jdt.ls.core.internal.ServiceStatus;
5152
import org.eclipse.jdt.ls.core.internal.codemanipulation.GenerateGetterSetterOperation.AccessorField;
@@ -445,10 +446,13 @@ public CompletableFuture<Object> shutdown() {
445446
@Override
446447
public void exit() {
447448
logInfo(">> exit");
448-
Executors.newSingleThreadScheduledExecutor().schedule(() -> {
449-
logInfo("Forcing exit after 1 min.");
450-
System.exit(FORCED_EXIT_CODE);
451-
}, 1, TimeUnit.MINUTES);
449+
LanguageServerApplication application = JavaLanguageServerPlugin.getLanguageServer();
450+
if (application != null && application.getParentProcessId() != ProcessHandle.current().pid()) {
451+
Executors.newSingleThreadScheduledExecutor().schedule(() -> {
452+
logInfo("Forcing exit after 1 min.");
453+
System.exit(FORCED_EXIT_CODE);
454+
}, 1, TimeUnit.MINUTES);
455+
}
452456
if (!shutdownReceived) {
453457
shutdownJob.schedule();
454458
}

0 commit comments

Comments
 (0)