From 62f0535ee262574c90a0ce6d61626208e4bcf35a Mon Sep 17 00:00:00 2001 From: akosyakov Date: Wed, 1 Jun 2016 13:22:38 +0200 Subject: [PATCH] [lsi] check whether the parent process is alive; exit if not Change-Id: I149f1c6a0a48a589f658af98956b30e2f1f952f7 Signed-off-by: akosyakov --- .../eclipse/xtext/ide/server/ServerLauncher.xtend | 15 ++++++--------- .../ide/tests/server/ServerLauncherTest.xtend | 2 ++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/plugins/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/ServerLauncher.xtend b/plugins/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/ServerLauncher.xtend index 1348446b0..ab635e017 100644 --- a/plugins/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/ServerLauncher.xtend +++ b/plugins/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/ServerLauncher.xtend @@ -11,12 +11,10 @@ import com.google.inject.Guice import com.google.inject.Inject import io.typefox.lsapi.NotificationMessage import io.typefox.lsapi.services.json.LanguageServerToJsonAdapter -import io.typefox.lsapi.services.json.MessageMethods import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.FileOutputStream import java.io.PrintStream -import java.util.concurrent.atomic.AtomicBoolean /** * @author Sven Efftinge - Initial contribution and API @@ -33,8 +31,6 @@ class ServerLauncher { @Inject LanguageServerImpl languageServer - private final AtomicBoolean hasExitNotification = new AtomicBoolean(false) - def void start() { val stdin = System.in val stdout = System.out @@ -46,9 +42,6 @@ class ServerLauncher { if (IS_DEBUG) { println(message) } - if (message.method == MessageMethods.EXIT) { - hasExitNotification.set(true); - } super._doAccept(message) } @@ -75,6 +68,11 @@ class ServerLauncher { super.sendResponseError(responseId, errorMessage, errorCode, errorData) } + override exit() { + System.err.println("Exit notification received. Good Bye!") + super.exit() + } + } messageAcceptor.protocol.addErrorListener[p1, p2| p2.printStackTrace(System.err) @@ -82,10 +80,9 @@ class ServerLauncher { messageAcceptor.connect(stdin, stdout) System.err.println("started.") messageAcceptor.join - while (!hasExitNotification.get) { + while (true) { Thread.sleep(10_000l) } - System.err.println("Exit notification received. Good Bye!") } def redirectStandardStreams() { diff --git a/tests/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/ServerLauncherTest.xtend b/tests/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/ServerLauncherTest.xtend index 2294de6af..734c2fbe3 100644 --- a/tests/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/ServerLauncherTest.xtend +++ b/tests/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/ServerLauncherTest.xtend @@ -48,6 +48,8 @@ class ServerLauncherTest { rootPath = "." ]).get Assert.assertTrue(msg != null) + client.shutdown + client.exit } } \ No newline at end of file