You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2020/11/09 13:57:39 UTC

[tinkerpop] branch master updated (2f5d57a -> 25364f7)

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


    from 2f5d57a  Added HugeGraph to provider listings
     add 9262a62  Fixed TestSupport file handling to work on windows.
     add 0024651  Added some comments.
     new 25364f7  Merge branch '3.4-dev'

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/tinkerpop/gremlin/util/TestSupport.java | 69 ++++++++++++++--------
 .../tinkerpop/gremlin/AbstractGraphProvider.java   |  2 +-
 2 files changed, 45 insertions(+), 26 deletions(-)


[tinkerpop] 01/01: Merge branch '3.4-dev'

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 25364f764ea9eea28e97df5eff5443e7b86b539f
Merge: 2f5d57a 0024651
Author: Stephen Mallette <st...@amazon.com>
AuthorDate: Mon Nov 9 08:57:19 2020 -0500

    Merge branch '3.4-dev'

 .../apache/tinkerpop/gremlin/util/TestSupport.java | 69 ++++++++++++++--------
 .../tinkerpop/gremlin/AbstractGraphProvider.java   |  2 +-
 2 files changed, 45 insertions(+), 26 deletions(-)

diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TestSupport.java
index 0f89200,ee10491..f6e29b3
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TestSupport.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TestSupport.java
@@@ -25,7 -27,9 +25,8 @@@ import java.io.FileOutputStream
  import java.io.IOException;
  import java.io.InputStream;
  import java.net.URL;
+ import java.nio.file.Files;
  import java.util.List;
 -import java.util.Random;
  import java.util.stream.Collectors;
  import java.util.stream.Stream;
  
@@@ -163,13 -171,27 +168,27 @@@ public class TestSupport 
                                                      final String resourceName, final String extension, final boolean overwrite) throws IOException {
          final File temp = makeTestDataPath(graphClass, "resources");
          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);
-                     }
+ 
+         // these checks are present mostly for windows compatibility where an outputstream created on a non-existent
 -        // file will cause an error. 
++        // file will cause an error.
+         if(tempFile.exists() && !overwrite){
+             // overwrite is disabled and file already exists -> reuse as-is
+             return tempFile;
+         }
+         if(!tempFile.getParentFile().exists()){
+             Files.createDirectories(tempFile.getParentFile().toPath());
+         }
+         // either the file does not exist or needs to be overwritten, drop it
+         Files.deleteIfExists(tempFile.toPath());
+         // create the new file
+         Files.createFile(tempFile.toPath());
+ 
+         // fill it with the desired contents
+         try (final FileOutputStream outputStream = new FileOutputStream(tempFile)) {
+             int data;
+             try (final InputStream inputStream = resourceClass.getResourceAsStream(resourceName)) {
+                 while ((data = inputStream.read()) != -1) {
+                     outputStream.write(data);
                  }
              }
          }