Menu

#6 Scanning fails for resources found on roots from Class-Path containing URL-encoded characters

1.x
open
nobody
None
2017-02-08
2017-02-08
No

When Surefire builds it’s Manifest Class-Path it looks like it URL encodes the strings. So a file path like this:

/var/lib/jenkins/workspace/all-unit-tests@2/services/target/classes/

… is added to the Class-Path property like this:

file:/var/lib/jenkins/workspace/all-unit-tests%402/services/target/classes/

When a resource is found it compares the resourceURL to the rootURL. The resourceURL has been decoded back to the original path but the rootURL has not been decoded. The result is this exception:

java.lang.IllegalArgumentException: The root URL "file:/var/lib/jenkins/workspace/all-unit-tests%402/services/target/classes/" is not root of the resource URL "file:/var/lib/jenkins/workspace/all-unit-tests@2/services/target/classes/db/cleaner/clean.sql"
    at net.sf.corn.cps.RootedURL.<init>(RootedURL.java:41)
    at net.sf.corn.cps.CPScanner.scan(CPScanner.java:380)
    at net.sf.corn.cps.CPScanner.scan(CPScanner.java:354)
    at net.sf.corn.cps.CPScanner.scan(CPScanner.java:354)
    at net.sf.corn.cps.CPScanner.scan(CPScanner.java:354)
    at net.sf.corn.cps.CPScanner.scan(CPScanner.java:332)
    at net.sf.corn.cps.CPScanner.scanResources(CPScanner.java:207)

This problem seems to be very specific to Class-Path entries that are referencing directories. If my Class-Path references a JAR it works fine even if the path has an encoded character in it.

Discussion


Log in to post a comment.