You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "René Kraneis (Jira)" <ji...@apache.org> on 2020/12/29 19:01:00 UTC

[jira] [Updated] (SUREFIRE-1869) Classloader.getResource() doesn't encode blanks with forkCount=0

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

René Kraneis updated SUREFIRE-1869:
-----------------------------------
    Description: 
We found this bug when running cucumber tests, having project paths with spaces and forkCount set to 0 (see [https://github.com/cucumber/cucumber-jvm/issues/2196] for the but report there). A minimal reproducing example would be
{code:java}
$ pwd
/home/rene/Projects/path with space/classpath test{code}
{code:java}
$ tree
.
├── pom.xml
└── src
    └── test
        └── java
            └── ClassPathTest.java{code}
{code:java}
$ cat src/test/java/ClassPathTest.java
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class ClassPathTest {
  public void testClassPath() throws IOException, URISyntaxException {
    URI uri = ClassPathTest.class.getClassLoader()
      .getResources(".")
      .nextElement()
      .toURI();
      System.out.println(uri);
  }
}{code}
{code:java}
$ mvn clean test -DforkCount=0
...
[INFO] --- maven-surefire-plugin:2.20:test (default-test) @ ClassPathTest ---
[WARNING] useSystemClassloader setting has no effect when not forking
[INFO] Running ClassPathTest
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.002 s <<< FAILURE! - in ClassPathTest
[ERROR] ClassPathTest.testClassPath()  Time elapsed: 0.001 s  <<< FAILURE!
java.net.URISyntaxException: Illegal character in path at index 29: file:/home/rene/Projects/path with space/classpath test/target/test-classes/
	at java.net.URI$Parser.fail(URI.java:2848)
	at java.net.URI$Parser.checkChars(URI.java:3021)
	at java.net.URI$Parser.parseHierarchical(URI.java:3105)
	at java.net.URI$Parser.parse(URI.java:3053)
	at java.net.URI.<init>(URI.java:588)
	at java.net.URL.toURI(URL.java:964)
	at ClassPathTest.testClassPath(ClassPathTest.java:13)
...
{code}
Last working version of surefire is 2.19.1. The build does not contain any additional dependencies and relies on pojo test execution. The same problem also happens when running tests with junit, junit vintage or junit platform.

  was:
We found this bug when running cucumber tests, having project paths with spaces and forkCount set to 0 (see [https://github.com/cucumber/cucumber-jvm/issues/2196] for the but report there). A minimal reproducing example would be
{code:java}
$ pwd
/home/rene/Projects/path with space/classpath test{code}
{code:java}
$ tree
.
├── pom.xml
└── src
    └── test
        └── java
            └── ClassPathTest.java{code}
{code:java}
$ cat src/test/java/ClassPathTest.java
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class ClassPathTest {
  public void testClassPath() throws IOException, URISyntaxException {
    URI uri = ClassPathTest.class.getClassLoader()
      .getResources(".")
      .nextElement()
      .toURI();
      System.out.println(uri);
  }
}{code}
Last working version of surefire is 2.19.1. The build does not contain any additional dependencies and relies on pojo test execution. The same problem also happens when running tests with junit, junit vintage or junit platform.


> Classloader.getResource() doesn't encode blanks with forkCount=0
> ----------------------------------------------------------------
>
>                 Key: SUREFIRE-1869
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1869
>             Project: Maven Surefire
>          Issue Type: Bug
>    Affects Versions: 2.20, 2.22.2, 3.0.0-M5
>            Reporter: René Kraneis
>            Priority: Major
>
> We found this bug when running cucumber tests, having project paths with spaces and forkCount set to 0 (see [https://github.com/cucumber/cucumber-jvm/issues/2196] for the but report there). A minimal reproducing example would be
> {code:java}
> $ pwd
> /home/rene/Projects/path with space/classpath test{code}
> {code:java}
> $ tree
> .
> ├── pom.xml
> └── src
>     └── test
>         └── java
>             └── ClassPathTest.java{code}
> {code:java}
> $ cat src/test/java/ClassPathTest.java
> import java.io.IOException;
> import java.net.URI;
> import java.net.URISyntaxException;
> public class ClassPathTest {
>   public void testClassPath() throws IOException, URISyntaxException {
>     URI uri = ClassPathTest.class.getClassLoader()
>       .getResources(".")
>       .nextElement()
>       .toURI();
>       System.out.println(uri);
>   }
> }{code}
> {code:java}
> $ mvn clean test -DforkCount=0
> ...
> [INFO] --- maven-surefire-plugin:2.20:test (default-test) @ ClassPathTest ---
> [WARNING] useSystemClassloader setting has no effect when not forking
> [INFO] Running ClassPathTest
> [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.002 s <<< FAILURE! - in ClassPathTest
> [ERROR] ClassPathTest.testClassPath()  Time elapsed: 0.001 s  <<< FAILURE!
> java.net.URISyntaxException: Illegal character in path at index 29: file:/home/rene/Projects/path with space/classpath test/target/test-classes/
> 	at java.net.URI$Parser.fail(URI.java:2848)
> 	at java.net.URI$Parser.checkChars(URI.java:3021)
> 	at java.net.URI$Parser.parseHierarchical(URI.java:3105)
> 	at java.net.URI$Parser.parse(URI.java:3053)
> 	at java.net.URI.<init>(URI.java:588)
> 	at java.net.URL.toURI(URL.java:964)
> 	at ClassPathTest.testClassPath(ClassPathTest.java:13)
> ...
> {code}
> Last working version of surefire is 2.19.1. The build does not contain any additional dependencies and relies on pojo test execution. The same problem also happens when running tests with junit, junit vintage or junit platform.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)