fix: resolve double-slash path in FileResolverImpl when fileName is root - #6281
Open
waterWang wants to merge 1 commit into
Open
fix: resolve double-slash path in FileResolverImpl when fileName is root#6281waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
|
the file listing is done on resource (which potentially can be a new path on the classpath) Otherwise it will try to locate the file in the root of your application/running instance? example in code:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #6280
When
FileResolverImpl.resolve()is called with an absolute path (e.g.,/application.yml), theparentFileloop inresolveFile2()reaches the root path/and callsunpackUrlResource(url, "/", cl, true). InunpackFromFileURL, when iterating over the directory listing, thesubResourceconstruction concatenatesfileName + "/" + file, producing//application.yml(double-slash prefix) instead of/application.yml.This causes the subsequent
getValidClassLoaderResource(cl, subResource)call to fail because//application.ymlis not a valid classpath resource path.Root cause
unpackFromFileURLunconditionally adds/betweenfileNameandfile, but whenfileNameis already/(the root path), this produces a double-slash prefix.Fix
Use a conditional separator: append
/only whenfileNamedoes not already end with/.Steps to reproduce
fileResolver.resolveFile("/application.yml")when the classloader has a resource root at a temp directory//application.ymlnot being found