Skip to content

fix: Keep Spring inspections unavailable while the IDE indexes instead of throwing IndexNotReadyException (#688) - #694

Merged
imuromtsev merged 5 commits into
mainfrom
imuromtsev/inspections-dumb-mode-availability
Oct 14, 2026
Merged

imuromtsev merged 5 commits into
mainfrom
imuromtsev/inspections-dumb-mode-availability

Conversation

@imuromtsev

Copy link
Copy Markdown
Collaborator

Purpose

While the IDE indexes, Spring inspections log one PluginException: Inspection tool '<name>' thrown exception from its buildVisitor() each (about 50 at once), caused by IndexNotReadyException:

IndexNotReadyException
  at JavaPsiFacadeImpl.findClass
  at LibraryClassCache.searchForLibraryClass
  at SpringBaseUastLocalInspectionTool.isAvailableForFile
  at Spring4UastLocalInspectionTool.isAvailableForFile
  at SpringBoot4Jackson2ObjectMapperInspection.isAvailableForFile
  at InspectionEngine.createVisitor

On IntelliJ 2026.2, InspectionEngine.createVisitor turns any non-control-flow exception from isAvailableForFile or buildVisitor into a logged PluginException. LocalInspectionsPass drops tools that are not DumbAware only when a pass starts, and other callers of InspectionEngine do not drop them at all, so isAvailableForFile of a Spring inspection can run while indexing. A project sync changes libraries and starts indexing at the same time, so the next availability check recomputes LibraryClassCache in dumb mode and throws.

Change

  • New InspectionAvailability in base: isIndexReady(file) and hasLibraryClass(file, fqn), which answers "not available" while the IDE indexes before any index access.
  • Both inspection base classes (SpringBaseUastLocalInspectionTool, SpringBaseLocalInspectionTool) and the four overrides that do not call super first (SpringBoot3JakartaMigrationInspection, SpringDataBaseUastLocalInspectionTool, SpringWebBaseUastLocalInspectionTool, SpringJdbcClientParamInspection) use it. Overrides that call super first are covered by the base classes. No inspection is DumbAware, so availability in smart mode is unchanged; the platform restarts highlighting when indexing ends.
  • LibraryClassCache is unchanged: a lookup that must compute while indexing still throws IndexNotReadyException, the platform's retry signal, so no cache built on it stores an answer computed during indexing.

Verification

  • Red commit 117d738: one test per base class and override (spring-core 5, spring-data 2, spring-web 1) asserts availability in smart mode, then calls isAvailableForFile in dumb mode with cold library caches; all failed with IndexNotReadyException.
  • Red commit 3ca9eac pins the LibraryClassCache contract: a cold lookup while indexing throws, and the class is found once indexing ends (no stale answer). The existing NativeSyncDumbModeTest pins the same contract for the native sync.
  • After the fixes (bdd8769, 7326787): the availability tests in spring-core 7/7, spring-data 2/2, spring-web 1/1; NativeSyncDumbModeTest 4/4; NativeLinkRepairServiceTest 15/15.
  • All modules (:spring-bootstrap:test --rerun-tasks on 7326787, fresh JUnit XML): spring-core 2394, spring-web 906 (6 skipped), spring-ai 776, spring-data 142, jpa 138, base 35, aop 6, security 6, initializr 5 — 0 failures except one Exodus ThreadLeakTracker leak assertion in SpringBootApplicationMcpToolsetTraceFunctionalRouteTest, which passed 40/40 when rerun alone (known flake).

Backport

Main first. The fix applies to every supported line (242–262) with per-line shapes: LibraryClassCache, SpringBaseLocalInspectionTool, SpringBoot3JakartaMigrationInspection and SpringJdbcClientParamInspection are identical on all release branches; SpringDataBaseUastLocalInspectionTool differs on 242–252; SpringWebBaseUastLocalInspectionTool does not exist on 242–252. Backport PRs follow after this one merges.

Closes #688

@imuromtsev imuromtsev added in:spring-core Spring Core or Spring Boot Core issues inspection threading EDT violations, read/write actions, dumb mode, freezes labels Oct 13, 2026
@github-actions

Copy link
Copy Markdown
TestsPassed ✅Skipped ⚠️Failed
JUnit Test Report4408 ran4402 passed6 skipped0 failed

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

Labels

in:spring-core Spring Core or Spring Boot Core issues inspection threading EDT violations, read/write actions, dumb mode, freezes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spring inspections throw IndexNotReadyException from isAvailableForFile while indexing

1 participant