Skip to content

sts.maven.goal deadlocks on builds that outgrow the pipe buffer: executeMaven never drains the child process #1950

Closed

Description

@luceat-lux-vestra

Describe the bug

DefaultBuildCommandProvider.executeMaven(Path, String[]) starts the build with

Runtime.getRuntime().exec(command, null, workingDir).onExit().thenAccept(…)

and nothing ever reads the child process's stdout/stderr. Runtime.exec connects those streams to pipes, so as soon as the build writes more than the OS pipe buffer (64 KiB on macOS) the child blocks on write, never exits, and the onExit() future never completes. The command then never returns to the client.

executeGradle in the same class has the identical shape.

Observed: sts.maven.goal invoked for the AOT goal on a Spring Boot 3.5.5 project — a build that completes in about 5 seconds when its output is drained — was still unfinished after 300 seconds. Running the same goal with the pipes drained completes normally, which is what identifies the buffer rather than the build as the cause.

Secondary effect from the same missing read: when the build fails fast enough not to deadlock, the failure reaches the client as a Java stack trace from the handler, and Maven's own diagnostic output is discarded — it was never read from the pipe.

To Reproduce

  1. Any Spring Boot project with a Maven wrapper.
  2. Invoke sts.maven.goal with a goal whose output exceeds the pipe buffer (~64 KiB), e.g. a full AOT/compile run rather than a trivial goal.
  3. The command does not return. The Maven process is alive but blocked on write.

A small goal that produces little output completes normally, which is why this is easy to miss in a quick test.

Suggested fix

Redirect or drain the child's streams — ProcessBuilder with redirectOutput/redirectError (or inheritIO), or reader threads on the existing Process — before waiting on exit. Draining also makes the real Maven diagnostic available for the failure path above.

Side note in the same method: executeGradle resolves gradlew.cmd on Windows, but the Gradle wrapper generates gradlew.bat.

Environment

  • Spring Tools 5.2.0.RELEASE (vscode-spring-boot 2.2.0), spring-boot-language-server-2.2.0-SNAPSHOT-exec.jar
  • Eclipse Temurin JDK 25.0.3, macOS 26.5.2 arm64

For transparency: observed by invoking the command over workspace/executeCommand from a non-VS Code LSP client running this same pinned language server. The handler does the work in-process, so the client is not involved in the behaviour described above.

Activity

  1. self-assigned this
    on Jul 29, 2026
  2. added this to the 5.4.0.RELEASE milestone on Jul 29, 2026
  3. BoykoAlex commented on Jul 29, 2026

    @BoykoAlex
    Contributor

    @luceat-lux-vestra can you list steps reproducing this in Eclipse or VSCode IDE please? Since you mentioned it is causing a deadlock with an AOT goal I suppose you've been able to see it?

  4. luceat-lux-vestra commented on Jul 29, 2026

    @luceat-lux-vestra
    Author

    Thanks for picking this up. Short answer: there are no such steps — this cannot be reached from Eclipse or VS Code at all. That is not a hole in the report, it is the scope of the bug, and I should have said so up front. Details below, plus what I actually ran.

    Why neither IDE can reach it

    JdtConfig#buildCommandProvider picks the provider from LspClient.currentClient():

    client provider
    VSCODE, THEIA, ECLIPSE VSCodeBuildCommandProvider
    default branch — UNKNOWN, ATOM, INTELLIJ DefaultBuildCommandProvider

    VSCodeBuildCommandProvider#executeMavenGoal only returns a Command (maven.goal.custom) for the client to run, so on that path the language server never spawns Maven. On top of that, sts.maven.goal and sts.gradle.build are registered with onCommand(...) inside DefaultBuildCommandProvider's constructor — in VS Code those commands aren't even handled server-side.

    Both IDEs really do announce themselves, so this is checked rather than assumed: vscode-extensions/commons-vscode/src/launch-util.ts passes -Dsts.lsp.client=vscode, and STS4LanguageServerProcessStreamConnector#fillCommand in org.springframework.tooling.ls.eclipse.commons passes -Dsts.lsp.client=eclipse.

    So the offending code is only live for clients that take the default branch — anything that doesn't set -Dsts.lsp.client.

    How narrow this is

    Since you should triage it with the real size in front of you: the default branch is not only "clients with no name". It also covers INTELLIJ and ATOM — values the enum defines — plus anything driving the language server directly (nvim/Emacs/Helix setups, and my own client).

    For one of those to hit the hang, three things have to line up: the client forwards sts.maven.goal to the server instead of handling it, the user triggers the Data AOT lens that is its only caller, and that build's output crosses the pipe buffer. That is narrow, and I would not call it urgent.

    The discarded-diagnostic half is wider, though — it needs no size threshold at all. Every failed build on this path loses Maven's explanation, and a one-line goal typo is enough to produce it (row 2 below).

    Yes, I saw it — here is how

    Client identity UNKNOWN, which is exactly that default branch: a non-VS Code LSP client that sets no sts.lsp.client property. I drove the pinned server jar directly over stdio JSON-RPC, no IDE in the picture — Spring Tools 5.2.0.RELEASE (spring-boot-language-server-2.2.0-SNAPSHOT-exec.jar), Temurin 25.0.3, macOS 26.5.2 arm64, a Spring Boot 3.5.5 project with a Maven wrapper:

    sts.maven.goal goal argument result
    compile org.springframework.boot:spring-boot-maven-plugin:process-aot result: null after 5,532 ms; AOT metadata really written
    org.springframework.boot:spring-boot-maven-plugin:no-such-goal JSON-RPC -32603 whose data is a Java stack trace — Maven's own diagnostic is nowhere in it
    -X compile org.springframework.boot:spring-boot-maven-plugin:process-aot no response after 300,005 ms; I cancelled it there

    Rows 1 and 3 are the same build. The only difference is how much it prints: run in a terminal with its output drained, the -X variant finishes in ~5 s and emits 120,402 bytes. That is what identifies the pipe buffer, not the build, as the cause — executeMaven waits on Process.onExit() and nothing ever reads the child's stdout/stderr, so once output passes the buffer (64 KiB here) the child blocks on write and never exits.

    Row 2 is the same missing read seen from the other side: when the build fails fast enough not to deadlock, Maven's explanation is still sitting unread in the pipe and gets discarded, so the client only receives the handler's stack trace.

    Client-independent reproducer

    1. Start spring-boot-language-server-*-exec.jar without -Dsts.lsp.client (or with -Dsts.lsp.client=unknown).
    2. initialize / initialized against a Boot project that has mvnw.
    3. workspace/executeCommand → sts.maven.goal, arguments ["<abs path to pom.xml>", "-X compile org.springframework.boot:spring-boot-maven-plugin:process-aot"].
    4. No response arrives. The mvnw child is still alive, blocked on write.

    -X is just a convenient way to cross the threshold on a small project; a large multi-module build, a noisy dependency resolution, or a long failure trace gets there on its own.

    I have a ~100-line Node script that does steps 1–3 and writes a transcript; happy to attach it or paste it as a gist if that's useful.

    Fix

    ProcessBuilder with redirectOutput/redirectError (or inheritIO), or reader threads on the existing Process, before waiting on exit. Draining also makes the real Maven diagnostic available for the failure path above. executeGradle has the identical shape, and separately resolves gradlew.cmd on Windows where the Gradle wrapper generates gradlew.bat.

    If the default provider is considered a legacy/unsupported path, closing this with that statement is a perfectly fine outcome from where I sit — I mainly wanted the behaviour on record, since any client that doesn't announce itself gets it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions