[
https://issues.apache.org/jira/browse/TINKERPOP-2465?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Stephen Mallette updated TINKERPOP-2465:
----------------------------------------
Affects Version/s: (was: 3.4.7)
(was: 3.4.6)
(was: 3.4.5)
(was: 3.4.4)
(was: 3.4.3)
(was: 3.4.2)
> 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)