-
Notifications
You must be signed in to change notification settings - Fork 38.9k
PathMatchingResourcePatternResolver doesn't work in fat-jar run scenario #28230
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
Affects: 5.3.17
I might have found an issue with classpath scanning of resources in a Bazel environment.
Here is some sample code:
URL resource1 = getClass().getResource("/files/resource1.txt");
LOG.debug("URL for '/files/resource1.text' is: {}", resource1);
URL resource2 = getClass().getResource("/files/resource2.txt");
LOG.debug("URL for '/files/resource2.text' is: {}", resource2);
final PathMatchingResourcePatternResolver resolver =
new PathMatchingResourcePatternResolver(MyBuilderCommand.class.getClassLoader());
Resource[] result = resolver.getResources("classpath*:/files/*.txt");
if (result.length == 0) {
LOG.error("No results returned from classpath for 'classpath*:/files/*.txt'");
}In all cases, accessing via getClass().getResource(..) always works. It's the resolver.getResources("classpath*:/files/*.txt") call that's failing in some cases.
Here are steps to reproduce:
git clone [email protected]:salesforce/bazel-java-builder-template.git
# works as expected
bazel run :mybuilder -- --current-target=foo -i BUILD -o /var/tmp/ --verbose
# does not work
bazel run :mybuilder2 -- --current-target=foo -i BUILD -o /var/tmp/ --verbose
# building a all-in-one-jar also doesn't work
bazel-bin/mybuilder2_deploy.jar
java -jar bazel-bin/mybuilder2_deploy.jar --current-target=foo -i BUILD -o /var/tmp/ --verboseThe difference is only in packaging. So I believe it must be something within PathMatchingResourcePatternResolver
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid