Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip searching of nonexistent directory in PathMatchingResourcePatternResolver #31111

Closed
rPraml opened this issue Aug 24, 2023 · 1 comment
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@rPraml
Copy link

rPraml commented Aug 24, 2023

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 24, 2023
@sbrannen sbrannen changed the title PathMatchingResourcePatternResolver fails with warning on non existent directory PathMatchingResourcePatternResolver fails with warning on non existent directory Aug 25, 2023
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Aug 25, 2023
@sbrannen sbrannen changed the title PathMatchingResourcePatternResolver fails with warning on non existent directory PathMatchingResourcePatternResolver logs warning for nonexistent directory Aug 25, 2023
@sbrannen sbrannen self-assigned this Aug 25, 2023
@sbrannen sbrannen added this to the 6.0.12 milestone Aug 25, 2023
@sbrannen sbrannen removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 25, 2023
@sbrannen sbrannen changed the title PathMatchingResourcePatternResolver logs warning for nonexistent directory Log INFO message for nonexistent directory in PathMatchingResourcePatternResolver Aug 25, 2023
@sbrannen
Copy link
Member

Hi @rPraml,

Thanks for the suggestion, and congratulations on submitting your fist issue for the Spring Framework! 👍

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].

We'll do something along those lines for 6.0.x.

Cheers,

Sam

@sbrannen sbrannen changed the title Log INFO message for nonexistent directory in PathMatchingResourcePatternResolver Skip searching of nonexistent directory in PathMatchingResourcePatternResolver Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants