Skip to content

AbstractFileResolvingResource.exists closes JAR resource input streams with v6.2.7 #34955

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

Open
marcrohlfs opened this issue May 27, 2025 · 2 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

@marcrohlfs
Copy link

Calling org.springframework.core.io.Resource#exists is called on a resource inside a JAR file (actually org.springframework.core.io.AbstractFileResolvingResource#exists in such cases), an input stream of whether the same or another resource in the same JAR file is (accidentally) closed. Trying to read (or continue reading) from such an input stream afterwards results in an java.io.IOException: Stream closed. The exist method should just answer it's intended question, but it should never change the state of an input stream.

This issue was introduced with v6.2.7, apparently with the fix for #34796.

I've created a small test project that shows some different combinations of resource reading along with exists checks: jar-resource-loader-test.zip

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 27, 2025
@jhoeller jhoeller self-assigned this May 27, 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: waiting-for-triage An issue we've not yet triaged or decided on labels May 27, 2025
@jhoeller jhoeller added this to the 6.2.8 milestone May 27, 2025
@ibrahimesseddyq

This comment has been minimized.

@bclozel

This comment has been minimized.

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

5 participants