Skip to content

Skip searching of nonexistent directory in PathMatchingResourcePatternResolver #31111

@rPraml

Description

@rPraml

Affects: 6.0.11

Hello, we perform resource scanning on several locations with this code.

@Getter
@Value("#{'${myproperties.allResources:classpath*:packages/all/**,file:config/packages/all/**}'.split(',')}")
private Resource[] all;

So we search for all resources in the JAR files in packages/all/** and (optionally) in the filesystem folder config/packages/all/**.

With the update from Spring Boot 2.7 to 3.0 we will get the warning in the console.

Failed to search in directory [/home/roland/myapp/config/packages/all] for files matching pattern [**]:
java.nio.file.NoSuchFileException: /home/roland/myapp/config/packages/all

As in my use case, this location is really optional. I don't like to present that warning to the user ;), as the warning will show up in the log file analysis.

The change was introduced with
4419d56#diff-69e11ca5877c77cb766565b03d43386f382f5321c62017d9e92f3615f6b3183eR762

I want to ask, if you think that it would make sense to check if rootPath really exists before Stream<Path> files = Files.walk(rootPath) is called and log this scenario not as warning but rather at INFO level -- for example, INFO: Skipping search in nonexistent directory [%s] for files matching pattern [%s].

Roland

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions