Repository navigation
Description
DataRepositoryAotMetadataService.getRepositoryMetadata decides where a repository's AOT metadata
file lives by switching on the project's build type:
switch (project.getProjectBuild().getType()) {
case ProjectBuild.MAVEN_PROJECT_TYPE: ...
case ProjectBuild.GRADLE_PROJECT_TYPE: ...
}That type is null whenever the build cannot be classified. ClasspathUtil.createProjectBuild
recognises Maven by the m2e nature, Gradle by the Buildship nature, and otherwise guesses from raw
classpath entries living under ~/.m2 or ~/.gradle. A project with none of those signals gets a
ProjectBuild whose type is null, and the switch throws:
java.lang.NullPointerException: Cannot invoke "String.hashCode()" because "<local4>" is null
at org.springframework.ide.vscode.boot.java.data.DataRepositoryAotMetadataService.getRepositoryMetadata(DataRepositoryAotMetadataService.java:142)
at org.springframework.ide.vscode.boot.java.data.DataRepositoryIndexer.identifyQueryString(DataRepositoryIndexer.java:189)
at org.springframework.ide.vscode.boot.java.data.DataRepositoryIndexer.indexQueryMethods(DataRepositoryIndexer.java:101)
at org.springframework.ide.vscode.boot.java.data.DataRepositoryIndexer.createReppsitoryBean(DataRepositoryIndexer.java:78)
at org.springframework.ide.vscode.boot.java.beans.ComponentIndexer.index(ComponentIndexer.java:78)
at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJavaAstScanner.extractSymbolInformation(SpringIndexerJavaAstScanner.java:167)
at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJavaAstScanner$1.lambda$visit$1(SpringIndexerJavaAstScanner.java:76)
at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJavaAstScanner.extractSafely(SpringIndexerJavaAstScanner.java:154)
What it costs
extractSafely catches per type declaration, so what is lost is not the one method being looked
at - the whole repository interface never reaches the index: no repository bean, none of its query
methods, nothing to navigate to or hover over.
identifyQueryString returns before this call when the method carries @Query, so the repositories
that disappear are exactly those declaring at least one derived query method (findAllByNameIn,
existsBy…, deleteBy…). On the workspace where I hit this - 116 projects, ~10.7k java files - 802
interfaces extend a Spring Data repository and 391 of them declare at least one method without
@Query. Everything else indexes normally (5023 Bean instances in the running server's heap),
which is what makes it easy to miss: the index looks healthy, repositories are simply absent from it.
Who runs into it
Any project whose build the server cannot classify as Maven or Gradle:
- the invisible project the language server creates for a plain folder;
- projects contributed by an importer from another extension - which is how I ran into it.
The shape that triggers it: a project with no pom.xml / build.gradle, no m2e or Buildship nature
and no classpath entries under ~/.m2 or ~/.gradle, holding a Spring Data repository with at least
one derived query method.
Fix
The switches in this class should answer "no metadata" for a build type they cannot read, which is
what they already do for any type that is neither maven nor gradle. PR to follow: a null-safe build
type used by both getRepositoryMetadata and regenerateMetadataCommand (the same switch, the same
problem), plus a test covering a build with no type and a missing build.
RewriteRecipeRepository.createRewriteProjectParser switches on the same value; its default branch
already throws IllegalStateException("The project is neither Maven nor Gradle!"), so a null type
there only replaces a clear message with an NPE. I left it alone - happy to fold it in if you would
rather have it in the same change.
Activity
[-]Spring Data repositories are dropped from the index when the project build is neither Maven nor Gradle (NPE in DataRepositoryAotMetadataService)[/-][+][5.4.1 backport] Spring Data repositories are dropped from the index when the project build is neither Maven nor Gradle (NPE in DataRepositoryAotMetadataService)[/+]BoykoAlex commentedon Oct 13, 2026
Fixed via a913ad6