You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by Jiading Guo <zi...@gmail.com> on 2022/05/12 14:15:06 UTC

TestSupport:::getRootOfBuildDirectory is broken on Windows

Hi all,

I'm new to TinkerPop and hope that this is the correct place to share.

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:

`file:/C:/Users/user/.m2/repository/org/apache/tinkerpop/gremlin-test/3.5.4-SNAPSHOT/gremlin-test-3.5.4-SNAPSHOT.jar!/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.class`

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:

`file:/home/user/.m2/repository/org/apache/tinkerpop/gremlin-test/3.5.4-SNAPSHOT/gremlin-test-3.5.4-SNAPSHOT.jar!/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.class`

It's great to test on Windows so I'm wondering if there could be a fix
for this? Thanks in advance!

Jiading Guo

Re: TestSupport:::getRootOfBuildDirectory is broken on Windows

Posted by Simon Zhao <si...@bitquilltech.com.INVALID>.
Hi Jiading,
Best practice would be to create temporary files in a designated folder one
without other files.
A quick solution that you can try which may resolve your issue is to replace
return File.createTempFile(fileName, fileNameSuffix, path);

with

return File.createTempFile(fileName, fileNameSuffix);

On Thu, May 12, 2022 at 7:26 AM Jiading Guo <zi...@gmail.com> wrote:

> Hi all,
>
> I'm new to TinkerPop and hope that this is the correct place to share.
>
> 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:
>
>
> `file:/C:/Users/user/.m2/repository/org/apache/tinkerpop/gremlin-test/3.5.4-SNAPSHOT/gremlin-test-3.5.4-SNAPSHOT.jar!/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.class`
>
> 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:
>
>
> `file:/home/user/.m2/repository/org/apache/tinkerpop/gremlin-test/3.5.4-SNAPSHOT/gremlin-test-3.5.4-SNAPSHOT.jar!/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.class`
>
> It's great to test on Windows so I'm wondering if there could be a fix
> for this? Thanks in advance!
>
> Jiading Guo
>


-- 

*Simon Zhao*
Software Developer
Bit Quill Technologies Inc.
Direct: 604-728-6911 | simonz@bitquilltech.com <sz...@bitquilltech.com>
https://www.bitquilltech.com

This email message is for the sole use of the intended recipient(s) and may
contain confidential and privileged information.  Any unauthorized review,
use, disclosure, or distribution is prohibited.  If you are not the
intended recipient, please contact the sender by reply email and destroy
all copies of the original message.  Thank you.