jglick commented on a change in pull request #197: SUREFIRE-1588 Patch (Java7)
URL: https://github.com/apache/maven-surefire/pull/197#discussion_r230093176
 
 

 ##########
 File path: 
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
 ##########
 @@ -111,7 +113,8 @@ private File createJar( @Nonnull List<String> classPath, 
@Nonnull String startCl
             for ( Iterator<String> it = classPath.iterator(); it.hasNext(); )
             {
                 File file1 = new File( it.next() );
-                String uri = file1.toURI().toASCIIString();
+
+                String uri = parent.relativize( file1.toPath() ).toString();
 
 Review comment:
   Not sure offhand what the paths here are like (have not yet tested this 
patch), but beware that this might throw `IllegalArgumentException` on Windows 
if they are on different drive letters. It might be wise to catch this 
exception and either
   
   * fall back to the original implementation and hope for the best
   * copy some of the classpath entries to a nearby location
   
   There is also a possible bug here with paths containing spaces or other 
special characters. From [what I can make 
out](https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#classpath),
 the expectation is that entries are relative URIs, not relative filenames. The 
original code used `File.toURI`, which escaped most characters into URI form 
(though NIO does a better job, for example handling Windows UNC paths). The new 
code uses `Path.toString`, which would not do that escaping. I suspect you 
meant to use
   
   ```suggestion
                   String uri = new URI(null, parent.relativize( file1.toPath() 
).toString(), null).toString();
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to