[ 
https://issues.apache.org/jira/browse/GROOVY-10663?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Justin Chu updated GROOVY-10663:
--------------------------------
    Description: 
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{}}}.

 

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

 
{code}
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)
...
{code}
 

Proposing the fix

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

 

Github PR: [https://github.com/apache/groovy/pull/1731]

  was:
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{}}}.

 

To reproduce the issue, include a plus sign in the {{groovyVersion}} in the 
{{{}gradle.properties{}}}, e.g. {{{}5.0.0+SNAPSHOT{}}}, then 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)
...}}

 

Proposing the fix

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

 

Github PR: https://github.com/apache/groovy/pull/1731


> PackageHelperImpl#getPackageNames unable to find package from path or jars 
> that contains plus sign
> --------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10663
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10663
>             Project: Groovy
>          Issue Type: Bug
>          Components: Groovysh
>    Affects Versions: 2.5.x, 5.x
>         Environment: Linux, java8u332
>            Reporter: Justin Chu
>            Priority: Minor
>
> 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{}}}.
>  
> To reproduce the issue, include a plus sign in the {{groovyVersion}} in the 
> {{{}gradle.properties{}}}, e.g. {{{}5.0.0+SNAPSHOT{}}}, then run the 
> {{{}PackageHelperImplTest{}}}, and {{testLoadAndGetPackagesEmpty}} would fail.
>  
> {code}
> 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)
> ...
> {code}
>  
> Proposing the fix
> Use {{Paths.get(url.toURI()).toFile()}} instead of {{{}new 
> File(URLDecoder.decode(url.file, 'UTF-8')){}}}.
>  
> Github PR: [https://github.com/apache/groovy/pull/1731]



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to