Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not exit if client and server are the same process. #2499

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ public class LanguageServerApplication implements IApplication {

@Override
public Object start(IApplicationContext context) throws Exception {

JavaLanguageServerPlugin.startLanguageServer(this);
synchronized (waitLock) {
while (!shutdown) {
@@ -61,7 +60,7 @@ public void setParentProcessId(long pid) {
/**
* @return the parentProcessId
*/
long getParentProcessId() {
public long getParentProcessId() {
return parentProcessId;
}
}
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@
import org.eclipse.jdt.ls.core.internal.JavaClientConnection.JavaLanguageClient;
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
import org.eclipse.jdt.ls.core.internal.JobHelpers;
import org.eclipse.jdt.ls.core.internal.LanguageServerApplication;
import org.eclipse.jdt.ls.core.internal.LanguageServerWorkingCopyOwner;
import org.eclipse.jdt.ls.core.internal.ServiceStatus;
import org.eclipse.jdt.ls.core.internal.codemanipulation.GenerateGetterSetterOperation.AccessorField;
@@ -448,10 +449,13 @@ public CompletableFuture<Object> shutdown() {
@Override
public void exit() {
logInfo(">> exit");
Executors.newSingleThreadScheduledExecutor().schedule(() -> {
logInfo("Forcing exit after 1 min.");
System.exit(FORCED_EXIT_CODE);
}, 1, TimeUnit.MINUTES);
LanguageServerApplication application = JavaLanguageServerPlugin.getLanguageServer();
if (application != null && application.getParentProcessId() != ProcessHandle.current().pid()) {
Executors.newSingleThreadScheduledExecutor().schedule(() -> {
logInfo("Forcing exit after 1 min.");
System.exit(FORCED_EXIT_CODE);
}, 1, TimeUnit.MINUTES);
}
if (!shutdownReceived) {
shutdownJob.schedule();
}