Skip to content

test: LanguageServerProcessNodesTest disposes the language server of a failed start once the server keeps its notification - #2331

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:test/cannot-start-notification-expiry
Nov 28, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:test/cannot-start-notification-expiry

Conversation

@lagergren

@lagergren lagergren commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2330

LanguageServerProcessNodesTest.testADisposedLanguageServerExpiresItsCannotStartNotification failed once on Linux, in the first CI run of #2328, which doesn't touch the LSP console. One test: commit, for contributors only; no change to LSP4IJ itself. For 0.30.2.

Cause: the test

LanguageServerWrapper.showNotificationStartServerError shows the "Cannot start server" notification, then keeps it in errorNotification, on the thread of the failed start. The test waited only until the notification was shown, so its dispose could come in between:

  1. The dispose finds no notification to expire.
  2. The thread of the start keeps the notification, sees that the language server was disposed, and expires it.
  3. The test had asserted between 1 and 2, at line 597.

The product is right in both orders. testACannotStartNotificationShownWhileItsLanguageServerIsDisposedExpires covers the dispose while the notification is shown, and waits for the expiry.

Fix

The test waits until the failed start reports its error to the lifecycle listeners (handleError), which it does once it kept the notification, before it disposes the language server. It still asserts that the dispose expires the notification at once.

Proof

With a temporary pause of one second in showNotificationStartServerError, between the notification and errorNotification = notification:

Test Result
The test as it was fails every time at line 597, as on CI: junit.framework.AssertionFailedError
The test as it is now passes, and so does testACannotStartNotificationShownWhileItsLanguageServerIsDisposedExpires

Without the pause, headless, with the counts from the JUnit XMLs:

IntelliJ LanguageServerProcessNodesTest Failures
IC 2024.2 47 0
IU 2026.3 47 0

…a failed start once the server keeps its notification

testADisposedLanguageServerExpiresItsCannotStartNotification disposed the language server as soon as its "Cannot start
server" notification was shown. LanguageServerWrapper keeps the notification only after it is shown, on the thread of
the failed start, so the dispose could come in between: it found no notification to expire, and the thread of the start
expired it right after, once the test had asserted. That case is what
testACannotStartNotificationShownWhileItsLanguageServerIsDisposedExpires covers.

The test now waits until the failed start reports its error, which it does once it kept the notification, and still
asserts that the dispose expires the notification at once.

With a pause of one second between the notification and its keeping, the test failed every time at the line where it
failed on CI. It passes with the pause now.

Fixes redhat-developer#2330
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated notification-expiry testing to wait for the server startup failure and its error notification before checking expiration.
    • Ensured lifecycle monitoring is cleaned up after the test, including when an assertion or callback fails.

The notification-expiry test now waits for the failed server’s lifecycle error and its “Cannot start server” notification before disposal. It then checks notification expiry and removes the lifecycle listener in a finally block.

Changes: Notification expiry test

Layer / File(s) Summary
Synchronize disposal with the error callback
src/test/java/com/redhat/devtools/lsp4ij/console/LanguageServerProcessNodesTest.java
The test records servers that receive handleError and waits for that callback and the “Cannot start server” notification before disposal. It checks notification expiry and removes the listener in a finally block.

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

Change: Other · Severity of issue fixed: Low

Suggested reviewers: d-biehl

Merge Risk: Minimal · up to 57659

This only changes a test, to remove a timing race. It waits for the failed start to report its error before disposing the language server, and still checks that disposal expires the notification. It does not affect plugin behavior and is low risk to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the test class and the behavior it now checks: disposing a language server after a failed start, once the server keeps its notification. This matches the only changed file and the stat…
Description check Passed The description explains the flaky test failure in LanguageServerProcessNodesTest, its cause (a race between the dispose and the failed-start thread keeping the notification), the fix (wait for handle…
Linked Issues check Passed Issue #2330 asks for a test-only fix. The test must wait until the failed start reports its error through LanguageServerLifecycleListener.handleError, after the notification is kept in errorNotificati…
Out of Scope Changes check Passed The change set, as described by the PR summary and change summary, touches only LanguageServerProcessNodesTest.java. The edits are the wait condition, the lifecycle listener registration and removal, …
Full details: Title check

Explanation

The title names the test class and the behavior it now checks: disposing a language server after a failed start, once the server keeps its notification. This matches the only changed file and the stated fix. The title uses the 'test:' prefix and states the main change. It is somewhat long (122 characters), but it is specific and readable.

Full details: Description check

Explanation

The description explains the flaky test failure in LanguageServerProcessNodesTest, its cause (a race between the dispose and the failed-start thread keeping the notification), the fix (wait for handleError before disposing), and the verification results. It is directly related to the changeset.

Full details: Linked Issues check

Explanation

Issue #2330 asks for a test-only fix. The test must wait until the failed start reports its error through LanguageServerLifecycleListener.handleError, after the notification is kept in errorNotification, and only then dispose the server. It must still assert that disposal expires the notification at once. The PR changes LanguageServerProcessNodesTest.testADisposedLanguageServerExpiresItsCannotStartNotification to wait for both the error callback and the "Cannot start server" notification before disposing. It also adds a lifecycle listener, removed in finally, and keeps the final expiry assertion. The PR description and the change summary both describe this behavior. The product code is not changed, which matches the issue's statement that the product already handles both event orders. Limitation: the diff text could not be read because the changed blobs are missing from the checkout, so this verdict rests on the PR description and the change summary, not on direct inspection of the changed lines.

Full details: Out of Scope Changes check

Explanation

The change set, as described by the PR summary and change summary, touches only LanguageServerProcessNodesTest.java. The edits are the wait condition, the lifecycle listener registration and removal, and the imports for the listener and JSON-RPC message types. These support the test fix for #2330. No product code is changed. Limitation: the diff text could not be read, so the absence of other changed files rests on the summary.

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: 6a5fb0f9-2543-4a57-bb2c-5e4e54d17f9b
Commits

Reviewing files that changed from the base of the PR and between 55f8b05 and 5765987.

Files selected for processing: 1

  • src/test/java/com/redhat/devtools/lsp4ij/console/LanguageServerProcessNodesTest.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.

@lagergren lagergren added this to the 0.30.2 milestone Nov 28, 2026
@codecov

codecov Bot commented Nov 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.63%. Comparing base (0c5aa98) to head (5765987).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2331   +/-   ##
=======================================
  Coverage   58.63%   58.63%           
=======================================
  Files         849      849           
  Lines       36704    36709    +5     
  Branches     7606     7608    +2     
=======================================
+ Hits        21520    21524    +4     
- Misses      12183    12189    +6     
+ Partials     3001     2996    -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 28, 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 174a093 into redhat-developer:main Nov 28, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant