Skip to content

A file whose tab closes before its selection's connection runs is connected again, which fails WorkspaceDiagnosticsTest on macOS #1842

Closed

Description

@lagergren

ConnectDocumentToLanguageServerSetupParticipant.selectionChanged connects the selected file in a non-blocking read action, which doesn't check that the file's tab is still open. If the read action runs after the tab has closed, and after the close's own read action has released the file's LSPFileSupport, it connects the file again. The server gets a didOpen for a file that no editor shows. The file then stays connected, because LSPFileListener.fileClosed has already run. A closed file's workspace diagnostics then go to that opened document instead of the closed-file cache.

On a slow machine this happens when a tab is closed soon after it was selected. It is what makes WorkspaceDiagnosticsTest.testCloseFiltersWorkspacePullWithoutPreviousResultId fail on macOS:

java.lang.NullPointerException: Cannot invoke "com.redhat.devtools.lsp4ij.ClosedDocument.getDiagnostics()" because the return value of "com.redhat.devtools.lsp4ij.LanguageServerWrapper.getClosedDocument(java.net.URI, boolean)" is null
    at com.redhat.devtools.lsp4ij.features.diagnostics.WorkspaceDiagnosticsTest.testCloseFiltersWorkspacePullWithoutPreviousResultId(WorkspaceDiagnosticsTest.java:524)

It failed this way in four of the twelve main runs since 2026-11-02 22:56 UTC: 41541450645 (13709b7d), 41545345490 (80a548ff), 41594514948 (2f4cea35) and 41594749898 (6175ca3b). It also failed in #1812's last run, 41609519586, on a commit that only changed documentation. Every failure was on macOS.

To reproduce: make the participant's read action wait until the file's tab has closed. The test then fails every time, with the same exception at the same line. On main (625621bb), the late read action finds the file without its LSPFileSupport, so it calls getLanguageServers, which connects the file.

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