Skip to content

TemplateJarRefreshActivityTest fails at times: it doesn't find its JAR once another test has listed the temp directory #2360

Done

Description

@lagergren

TemplateJarRefreshActivityTest failed on IntelliJ 2025.3 in the CI run of #2355, which doesn't touch the templates. Its three tests that build a JAR failed at their first assertTemplates, and testGetTemplateRootNeverRefreshes passed. None of the 25 CI jobs that failed since the test was added on 2026-11-24 (#2190) failed in it.

junit.framework.AssertionFailedError
    at com.redhat.devtools.lsp4ij.templates.TemplateJarRefreshActivityTest.assertTemplates(TemplateJarRefreshActivityTest.java:167)

Line 167 asserts that JarFileSystem.findFileByPath finds the templates/lsp folder of the test's JAR.

Cause: the test

Each test builds its JAR in a new folder of the temp directory, then looks it up with findFileByPath, without a refresh. The VFS looks on disk for a file it hasn't seen yet only in a folder whose children it hasn't listed yet. Once another test of the same JVM has listed the temp directory, the VFS doesn't find the new folder, and so neither the JAR. Which tests share a JVM, and in which order they run, varies with CI's three test forks. Which test lists the temp directory isn't known.

LSP4IJ itself isn't affected: TemplateJarRefreshActivity looks up LSP4IJ's own JAR, which the VFS knows from the IDE's previous start, when it read the templates from it.

Proof

With the temp directory listed in setUp (getChildren() of its VFS file) before the test creates its folder, the same three tests fail every time at line 167, as on CI, and testGetTemplateRootNeverRefreshes passes.

Fix

The first build of a test's JAR is looked up with refreshAndFindFileByNioFile, as the IDE knows the JAR from which it read the templates at its previous start. The later builds aren't refreshed, so that the tests still see what the VFS has cached of the old JAR.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions