Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Cannot Reproduce
-
3.5.0, 3.5.1, 3.6.0, 3.5.2, 3.5.3
-
None
-
None
-
Windows 10
Description
Inital discussion is in mailing list [1], I propose the solution but only reply to Simon accidentally. I'll post it here since Jira seems to be the palce for bug and fix.
When calling `TestSupport:::generateTempFile`, the code goes to `TestSupport.java:L122`:
```
final String clsUri = clazz.getName().replace(".", "/") + ".class";
final URL url = clazz.getClassLoader().getResource(clsUri);
final String clsPath = url.getPath();
final String computePath = clsPath.substring(0, clsPath.length() - clsUri.length());
```
on Windows the `clsPath` is something like:
and it then failed on `File.createTempFile(fileName, fileNameSuffix, path)` with
`java.io.IOException: The filename, directory name, or volume label syntax is incorrect`
In Linux this works fine as `clsPath` is resolved to:
After some searching[2], maybe we could use URI or use substring like this?
```
// getRootOfBuildDirectory
final String clsUri = clazz.getName().replace(".", "/") + ".class";
final URL url = clazz.getClassLoader().getResource(clsUri);
final String FILE_PREFIX = "file:";
final String clsPath = url.getPath().substring(FILE_PREFIX.length());
final String computePath = clsPath.substring(0, clsPath.length() -
clsUri.length());
```
The code worked on both Linux and Windows in my test. If needed I
could submit a PR.
[1] https://lists.apache.org/thread/lny64h5yjfoongwm1gtsydwc9pcvk6xj
[2] https://stackoverflow.com/questions/45782535/classloader-getresource-returns-odd-path-maybe