[ 
https://issues.apache.org/jira/browse/TINKERPOP-2465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17227560#comment-17227560
 ] 

Martin Häusler commented on TINKERPOP-2465:
-------------------------------------------

[~spmallette] I've created a pull request for this issue on github. Sadly it 
won't help me (yet) because 3.5.x (which, to my understanding, isn't released 
yet?) uses a different Apache Configurations version. Also, this particular 
method seems to have moved as well, it resides in "TestSupport" on the master 
branch, not in "TestHelper" anymore. Could you perhaps do me a favour and 
backport my fix to 3.4.x?

> TestHelper.generateTempFileFromResource file handling is invalid on windows
> ---------------------------------------------------------------------------
>
>                 Key: TINKERPOP-2465
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2465
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: test-suite
>    Affects Versions: 3.4.8
>         Environment: Windows
>            Reporter: Martin Häusler
>            Priority: Major
>
> In org.apache.tinkerpop.gremlin.TestHelper there's a method 
> "generateTempFileFromResource":
> {code:java}
> public static File generateTempFileFromResource(final Class graphClass, final 
> Class resourceClass, final String resourceName, final String extension, final 
> boolean overwrite) throws IOException {
>     final File temp = makeTestDataPath(graphClass, "resources");
>     if (!temp.exists()) temp.mkdirs();
>     final File tempFile = new File(temp, resourceName + extension);
>     if (!tempFile.exists() || overwrite) {
>         try (final FileOutputStream outputStream = new 
> FileOutputStream(tempFile)) {
>             int data;
>             try (final InputStream inputStream = 
> resourceClass.getResourceAsStream(resourceName)) {
>                 while ((data = inputStream.read()) != -1) {
>                     outputStream.write(data);
>                 }
>             }
>         }
>     }
>     return tempFile;
> }
> {code}
> The problem with this method is this section:
> {code:java}
>  if (!tempFile.exists() || overwrite) { try (final FileOutputStream 
> outputStream = new FileOutputStream(tempFile)) {
> {code}
> If the temp file does not exist, a new FileOutputStream is created. However, 
> the way the file system reacts to a file output stream being created on a 
> non-existing file is not the same across all file systems. In particular on 
> windows, the file system will throw an error in this case, indicating that 
> the file does not exist.
>  
> This effectively breaks the gremlin test suite when it's running on windows.
>  
> The fix would be to first create the file, then opening the file output 
> stream on it.
>  



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

Reply via email to