Skip to content

Commit

Permalink
fix - Gradle server will terminate if generatePipepath error (#1557)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiaaming authored Aug 5, 2024
1 parent e692c0c commit 2d816ba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 4 additions & 0 deletions extension/src/languageServer/languageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export async function startLanguageClientAndWaitForConnection(
rootProjectsStore: RootProjectsStore,
languageServerPipePath: string
): Promise<void> {
if (languageServerPipePath === "") {
isLanguageServerStarted = false;
return;
}
void vscode.window.withProgress({ location: vscode.ProgressLocation.Window }, (progress) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return new Promise<void>(async (resolve) => {
Expand Down
4 changes: 2 additions & 2 deletions extension/src/server/GradleServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class GradleServer {
private setLanguageServerPipePath(): void {
this.languageServerPipePath = getRandomPipeName();
if (this.languageServerPipePath === "") {
this.logger.error("Failed to generate language server pipe path, language server will not start");
this.logger.error("Gradle language server will not start due to pipe path generation failure");
}
}

Expand All @@ -55,7 +55,7 @@ export class GradleServer {
if (isPrepared) {
startBuildServer = true;
} else {
this.logger.error("Failed to generate build server pipe path, build server will not start");
this.logger.error("Gradle build server will not start due to pipe path generation failure");
}
}
this.bspProxy.setBuildServerStarted(startBuildServer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.lsp4j.CompletionOptions;
import org.eclipse.lsp4j.DocumentFilter;
import org.eclipse.lsp4j.ExecuteCommandOptions;
Expand All @@ -43,9 +42,6 @@ public class GradleLanguageServer implements LanguageServer, LanguageClientAware

public static void main(String[] args) {
GradleLanguageServer server = new GradleLanguageServer();
if (StringUtils.isBlank(args[0])) {
server.exit();
}
try {
NamedPipeStream pipeStream = new NamedPipeStream(args[0]);

Expand All @@ -55,7 +51,7 @@ public static void main(String[] args) {
server.connect(launcher.getRemoteProxy());
launcher.startListening();
} catch (IOException e) {
server.exit();
throw new RuntimeException("Gradle language server start failed", e);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.badsyntax.gradle;

import com.github.badsyntax.gradle.utils.Utils;
import com.google.common.base.Strings;
import com.microsoft.gradle.GradleLanguageServer;
import io.grpc.Server;
import io.grpc.ServerBuilder;
Expand Down Expand Up @@ -62,8 +63,10 @@ public static void main(String[] args) throws Exception {
int taskServerPort = Integer.parseInt(Utils.validateRequiredParam(params, "port"));
startTaskServerThread(taskServerPort);

String languageServerPipePath = Utils.validateRequiredParam(params, "languageServerPipePath");
startLanguageServerThread(languageServerPipePath);
String languageServerPipePath = params.get("languageServerPipePath");
if (!Strings.isNullOrEmpty(languageServerPipePath)) {
startLanguageServerThread(languageServerPipePath);
}

boolean startBuildServer = Boolean.parseBoolean(Utils.validateRequiredParam(params, "startBuildServer"));
if (startBuildServer) {
Expand Down

0 comments on commit 2d816ba

Please sign in to comment.