Skip to content

lsp4j client shutdown #924

@ChGen

Description

@ChGen

Hi, I'm using lsp4j:0.24.0 java client with clangd server. Client works, but something related to lsp4j client still holding the process for exactly one minute after shutdown completed, clangd process quit and java main() is finished. What I'm doing wrong related to cleanup order of lsp4j client?
openjdk 17, Ubuntu 24.04 x86_64.

// In constructor:
final ProcessBuilder clangdProcessBuilder = new ProcessBuilder(
	clangdPath, ... , "--log=verbose"
);
final Process clangdProcess = clangdProcessBuilder.start();
this.inputStream = clangdProcess.getInputStream();
this.outputStream = clangdProcess.getOutputStream();
Launcher<LanguageServer> launcher = LSPLauncher.createClientLauncher(this, this.inputStream, this.outputStream);
launcherFuture = launcher.startListening();
this.server = launcher.getRemoteProxy();

....

// In close():
this.server.shutdown().thenRun(() -> {
	this.server.exit();
	this.launcherFuture.cancel(true);
}).join();
this.inputStream.close();
this.outputStream.close();
System.err.println("Clangd server shutdown completed");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions