Hi I got a problem with springboot 2.3.1 when I try to load a resource from the root resource directory. I provided a minimal example with a unit test that reproduces the problem here:
https://github.com/Captain-P-Goldfish/springboot-2.3.1-error
When I execute the following line
getClass().getResource("/").getFile()
I get the following result:
file:/D:/maven-repository/org/junit/platform/junit-platform-commons/1.5.2/junit-platform-commons-1.5.2.jar!/META-INF/versions/9
This happens only if springboot 2.3.1 is within the classpath. Remove it and the problem is gone
Comment From: wilkinsona
Thanks for the sample. Unfortunately, it does not reproduce the behaviour that you have described on either macOS or Windows. Running on the latter produces the following output:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running de.spring.test.SpringbootAppTest
06 Jul 2020 17:16:03,055 [main] WARN (SpringbootAppTest.java:20) - resourcePath: /c:/dev/temp/springboot-2.3.1-error/target/test-classes/log4j2.xml
06 Jul 2020 17:16:03,059 [main] WARN (SpringbootAppTest.java:21) - resourcePath2: /c:/dev/temp/springboot-2.3.1-error/target/test-classes/log4j2.xml
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec
Looking at the code, I also can't see any reason why Spring Boot's presence on the classpath would have an effect. It's not being used anywhere and I suspect that none of its classes are being loaded.
If you'd like us to spend some more time investigating we'll need a sample that reproduces the behaviour that you have described.
Comment From: Captain-P-Goldfish
I see I normally start my tests from the IDE. I just noticed that it seems only to fail with IntelliJ. It worked with eclipse though.
Comment From: Captain-P-Goldfish
I reported the issue also on the jetbrains platform. I have absolutely no idea if springboot or IntelliJ is causing this... https://youtrack.jetbrains.com/issue/IDEA-245314
Comment From: wilkinsona
Given that it only occurs with IntelliJ, I think it's likely that it is the cause of the problem. If that turns out not to be the case, please let us know and we can re-open this issue and investigate further.