Skip to content

GROOVY-10663: Fixed issue in PackageHelperImpl#getPackageNames#1731

Merged
paulk-asert merged 1 commit into
apache:masterfrom
justinchuch:fix-packagehelperimpl
Jun 22, 2022
Merged

GROOVY-10663: Fixed issue in PackageHelperImpl#getPackageNames#1731
paulk-asert merged 1 commit into
apache:masterfrom
justinchuch:fix-packagehelperimpl

Conversation

@justinchuch
Copy link
Copy Markdown
Contributor

@justinchuch justinchuch commented Jun 21, 2022

Issue

PackageHelperImpl#getPackageNames would not be able to find and return
the package names if the package path or filename of the jar contains
plus signs due to the behavior of URLDecoder#decode.

URLDecoder#decode would decode the plus sign (i.e. +) as empty space, causing java.io.FileNotFoundException.

Reproduction

To reproduce the case, include a plus sign in the groovyVersion in the gradle.properties, e.g. 5.0.0+SNAPSHOT, run the PackageHelperImplTest, and testLoadAndGetPackagesEmpty would fail.

WARN [org.apache.groovy.groovysh.util.PackageHelperImpl] Error opening jar file : '/home/jus/repos/apache/groovy/build/libs/groovy-raw-5.0.0+SNAPSHOT.jar' : java.io.FileNotFoundException: /home/jus/repos/apache/groovy/build/libs/groovy-raw-5.0.0 SNAPSHOT.jar (No such file or directory)
...

Proposed fix

Use Paths.get(url.toURI()).toFile() instead of new File(URLDecoder.decode(url.file, 'UTF-8')).

@justinchuch justinchuch changed the title Fixed issue in PackageHelperImpl#getPackageNames GROOVY-10663: Fixed issue in PackageHelperImpl#getPackageNames Jun 21, 2022
@justinchuch justinchuch force-pushed the fix-packagehelperimpl branch from d859f36 to a3d4623 Compare June 21, 2022 23:32
PackageHelperImpl#getPackageNames would not be able to find and return
the package names if the package path or filename of the jar contains
plus signs due to the behavior of URLDecoder#decode.
@justinchuch justinchuch force-pushed the fix-packagehelperimpl branch from a3d4623 to 9a0799b Compare June 22, 2022 03:45
@paulk-asert paulk-asert merged commit 0e81e93 into apache:master Jun 22, 2022
@paulk-asert
Copy link
Copy Markdown
Contributor

Looks good - merged!

@justinchuch justinchuch deleted the fix-packagehelperimpl branch July 3, 2022 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants