You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WorkspaceDiagnosticsTest matches an unchanged report again when its file's document is collected #1836
WorkspaceDiagnosticsTest fails now and then in the tests that go through assertUnchangedMatchInvalidation. On #1835's Ubuntu job, testUnrelatedUnsavedEditsDoNotInvalidateMatching failed with:
junit.framework.AssertionFailedError: An unchanged report must reuse matching expected:<1> but was:<2>
at com.redhat.devtools.lsp4ij.features.diagnostics.WorkspaceDiagnosticsTest.assertUnchangedMatchInvalidation(WorkspaceDiagnosticsTest.java:320)
at com.redhat.devtools.lsp4ij.features.diagnostics.WorkspaceDiagnosticsTest.testUnrelatedUnsavedEditsDoNotInvalidateMatching(WorkspaceDiagnosticsTest.java:275)
On main (e96dee9c), running the class three times on macOS failed once, in testUnchangedReportsReuseMatchesUntilDefinitionChanges, at the same assertion.
Cause
WorkspaceDiagnosticManager reuses a match for an unchanged report only while the file's matching version is unchanged. LanguageClientImpl.workspaceDiagnosticMatchingVersion includes the stamp of the file's cached document, FileDocumentManager.getCachedDocument(file), or 0 when there is none.
assertUnchangedMatchInvalidation loads that document before the first report, to have it in the matching version: assertNotNull(FileDocumentManager.getInstance().getDocument(file)). It doesn't keep it, though, and FileDocumentManagerBase keeps an unmodified document only in a weak-value map (myDocumentCache, CollectionFactory.createConcurrentWeakValueMap()). When a garbage collection between the full report and the unchanged report clears it, the document's part of the version goes from the file's stamp to 0. The unchanged report is then matched again, and the count is 2.
For the client this is harmless, just one more match.
Expected
The test keeps the document until it ends, so that its outcome doesn't depend on when the JVM collects garbage.
Activity
test: keep the document whose retained match WorkspaceDiagnosticsTest…
fix: keep a language server kept alive while its last-document stop i…