Skip to content

fix: start no language server that is switched off for a feature that still holds it - #2037

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/no-start-of-a-switched-off-language-server
Nov 20, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/no-start-of-a-switched-off-language-server

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #2036.

LanguageServerWrapper.start() returned early only for a disposed
language server, so getInitializedServer() started a language server
that is switched off for a feature that still holds it, as the quick
fixes of the diagnostics that it showed do (LSPLazyCodeActions). Such a
language server ran while switched off, and when it started while its
stop ran, the stop never ended as stopped: it sets that status only if
no start replaced its attempt meanwhile.

start() now starts nothing while the language server is switched off,
as for one that is disposed: getInitializedServer() and connect()
then give no language server, as they do for one that cannot start.
LanguageServerManager, restart() and Enable and Start switch a
language server on before they start it.

Test: LanguageServerManagerInstancesTest.testAFeatureThatStillHoldsAnInstanceSwitchedOffDoesNotStartIt
asks an instance for its language server while stopAndDisable() stops
it and once it is stopped: it gets none, and the instance stays stopped
and switched off. Without the change, the instance is never stopped, as
in the CI failure of
testEnableAndStartOfAnInstanceWhichFailedStartsDisabledStartsNoOtherStoppedInstance
that found it. All tests pass (1763, 7 skipped, as on main).

… still holds it

Fixes redhat-developer#2036.

`LanguageServerWrapper.start()` returned early only for a disposed
language server, so `getInitializedServer()` started a language server
that is switched off for a feature that still holds it, as the quick
fixes of the diagnostics that it showed do (`LSPLazyCodeActions`). Such a
language server ran while switched off, and when it started while its
stop ran, the stop never ended as `stopped`: it sets that status only if
no start replaced its attempt meanwhile.

`start()` now starts nothing while the language server is switched off,
as for one that is disposed: `getInitializedServer()` and `connect()`
then give no language server, as they do for one that cannot start.
`LanguageServerManager`, `restart()` and *Enable and Start* switch a
language server on before they start it.

Test: `LanguageServerManagerInstancesTest.testAFeatureThatStillHoldsAnInstanceSwitchedOffDoesNotStartIt`
asks an instance for its language server while `stopAndDisable()` stops
it and once it is stopped: it gets none, and the instance stays stopped
and switched off. Without the change, the instance is never stopped, as
in the CI failure of
`testEnableAndStartOfAnInstanceWhichFailedStartsDisabledStartsNoOtherStoppedInstance`
that found it. All tests pass (1763, 7 skipped, as on `main`).
@lagergren lagergren added this to the 0.30.2 milestone Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Disabled language server instances no longer start when a start request occurs, including while stopping or after they have stopped.
    • Requests for an initialized server now resolve to no server for disabled instances.

LanguageServerWrapper.start() now exits when the wrapper is disabled. A regression test checks that requests for the initialized server do not restart a disabled instance during or after shutdown.

Changes: Disabled language server startup

Layer / File(s) Summary
Startup guard and regression test
src/main/java/com/redhat/devtools/lsp4ij/LanguageServerWrapper.java, src/test/java/com/redhat/devtools/lsp4ij/LanguageServerManagerInstancesTest.java
start() now returns when the wrapper is disabled. The test checks that initialized-server futures resolve to null during and after shutdown, and that event dispatch leaves the instance stopped and disabled.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: d-biehl, angelozerr

Merge Risk: Minimal · up to 1c109

This change stops a disabled language server from being restarted when a feature still holds it and requests its server. The change is small and covered by a regression test, and no merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: LanguageServerWrapper.start() no longer starts a language server that is switched off, even when a feature still holds it. The raw summary, objectives, and description…
Description check Passed The description states the bug (start() returns early only for disposed servers), the fix (start() starts nothing while switched off), the affected APIs, and a targeted test. It matches the changeset …
Linked Issues check Passed Direct issue #2036 requires that LanguageServerWrapper.start() not start a language server that is switched off, for disabled-by-stopAndDisable(), definition or instance stops, and too many failed…
Out of Scope Changes check Passed The changed files are LanguageServerWrapper.java (the start guard, +8/-4) and LanguageServerManagerInstancesTest.java (one new test, +21/-0). The guard change is the fix that issue #2036 requests.…
Full details: Title check

Explanation

The title names the main change: LanguageServerWrapper.start() no longer starts a language server that is switched off, even when a feature still holds it. The raw summary, objectives, and description all describe this same change, so the title is specific and accurate.

Full details: Description check

Explanation

The description states the bug (start() returns early only for disposed servers), the fix (start() starts nothing while switched off), the affected APIs, and a targeted test. It matches the changeset and the linked issue #2036.

Full details: Linked Issues check

Explanation

Direct issue #2036 requires that LanguageServerWrapper.start() not start a language server that is switched off, for disabled-by-stopAndDisable(), definition or instance stops, and too many failed starts. The change summary for LanguageServerWrapper.java states that start() now returns early whenever isEnabled() is false, not only when disposed. This covers the switched-off states that the issue lists, so getInitializedServer() no longer restarts a disabled instance. The added test LanguageServerManagerInstancesTest.testAFeatureThatStillHoldsAnInstanceSwitchedOffDoesNotStartIt checks the stopping and stopped cases and that the instance remains stopped and disabled. The issue states that LanguageServerManager, restart(), and Enable and Start already switch a server on before starting it, so those paths are unchanged. Limitation: the file read of LanguageServerWrapper.java at head was truncated and the diff tool was unavailable, so the exact isEnabled() body and the stop ordering were not read directly. The verdict relies on the change summary and the test description.

Full details: Out of Scope Changes check

Explanation

The changed files are LanguageServerWrapper.java (the start guard, +8/-4) and LanguageServerManagerInstancesTest.java (one new test, +21/-0). The guard change is the fix that issue #2036 requests. The test checks that fix. No unrelated change appears in the supplied change summaries. The diff tool could not produce a text diff, so the line-level content was not verified directly.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d02d0135-d8c2-4198-92a6-70ddb4e11de2
Commits

Reviewing files that changed from the base of the PR and between 13916a2 and 1c109ea.

Files selected for processing: 2

  • src/main/java/com/redhat/devtools/lsp4ij/LanguageServerWrapper.java
  • src/test/java/com/redhat/devtools/lsp4ij/LanguageServerManagerInstancesTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.44%. Comparing base (13916a2) to head (1c109ea).

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #2037     +/-   ##
=========================================
  Coverage   49.43%   49.44%             
=========================================
  Files         813      813             
  Lines       33324    33324             
  Branches     6848     5191   -1657     
=========================================
+ Hits        16473    16476      +3     
- Misses      14278    14280      +2     
+ Partials     2573     2568      -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit 0af1afc into redhat-developer:main Nov 20, 2026
9 checks passed
@lagergren lagergren added the bug Something isn't working label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A language server that is switched off starts again when a feature asks it for its language server

1 participant