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

PathMatchingResourcePatternResolver is not able to resolve file in SpringBoot Packaged JAR #34126

Closed
pawank94 opened this issue Dec 20, 2024 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Milestone

Comments

@pawank94
Copy link

pawank94 commented Dec 20, 2024

This issue is happening for Spring Boot generated JAR file
When resolving for a path in JAR file jar:file:~/Documents/_GIT/xxxxx/example.jar!/BOOT-INF/classes!/com/xxxx in PathMatchingResourcePatternResolver. . The changes done in this commit seem to cause an issue.

Old Code:

for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements(); ) {
				JarEntry entry = entries.nextElement();
				String entryPath = entry.getName();
				entryCache.add(entryPath);
				if (entryPath.startsWith(rootEntryPath)) {

New Code

for (String entryPath : jarFile.stream().map(JarEntry::getName).sorted().toList()) {
				entriesCache.add(entryPath);
				if (entryPath.startsWith(rootEntryPath)) {

Upon analyzing, I noticed jarFile.entries() produces a different file path compared to jarFile.stream().map(JarEntry::getName). For the new code, the generated entryPath has the BOOT-INFO/ prefix added to it and the following .startsWith() check fails because of that.

This creates problems in resolving a resource in the Spring-Boot generated JAR File for New Code.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 20, 2024
@snicoll
Copy link
Member

snicoll commented Jan 9, 2025

Duplicate #34111

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2025
@snicoll snicoll added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 9, 2025
@jhoeller
Copy link
Contributor

This seems to be a separate nuance as well, reopening for a specific refinement in the entry path comparison there.

@jhoeller jhoeller reopened this Jan 12, 2025
@jhoeller jhoeller added type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) and removed status: duplicate A duplicate of another issue labels Jan 12, 2025
@jhoeller jhoeller self-assigned this Jan 12, 2025
@jhoeller jhoeller added this to the 6.2.2 milestone Jan 12, 2025
@jhoeller
Copy link
Contributor

@pawank94 this is available in the latest 6.2.2 snapshot now, please give it an early try if you have the chance (before 6.2.2 becomes generally available on Thursday).

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: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

4 participants