TinkerGraph's would not save on close()

if the path was just a file name. Tested "just a file name" manually and added 
a test for relative paths - didn't want to generate test data outside of our 
test directories. TINKERPOP-1451


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/371bb39c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/371bb39c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/371bb39c

Branch: refs/heads/TINKERPOP-1115
Commit: 371bb39c5c23bb766f391974ea024219a5941fe8
Parents: e7e7481
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Sep 15 13:51:33 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Sep 15 14:41:00 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../tinkergraph/structure/TinkerGraph.java      |  4 +++-
 .../tinkergraph/structure/TinkerGraphTest.java  | 22 ++++++++++++++++++++
 3 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/371bb39c/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 4d990ee..6984b58 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -27,6 +27,7 @@ TinkerPop 3.1.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 * Removed the `appveyor.yml` file as the AppVeyor build is no longer enabled 
by Apache Infrastructure.
+* Fixed TinkerGraph which was not saving on `close()` if the path only 
consisted of the file name.
 * Fixed a bug in `RangeByIsCountStrategy` which didn't use the `NotStep` 
properly.
 
 [[release-3-1-4]]

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/371bb39c/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
----------------------------------------------------------------------
diff --git 
a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
 
b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
index af7245a..5df47b6 100644
--- 
a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
+++ 
b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
@@ -299,7 +299,9 @@ public final class TinkerGraph implements Graph {
             f.delete();
         } else {
             final File parent = f.getParentFile();
-            if (!parent.exists()) {
+
+            // the parent would be null in the case of an relative path if the 
graphLocation was simply: "f.gryo"
+            if (parent != null && !parent.exists()) {
                 parent.mkdirs();
             }
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/371bb39c/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --git 
a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
 
b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index fca1275..e9b7f7b 100644
--- 
a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ 
b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -440,6 +440,28 @@ public class TinkerGraphTest {
     }
 
     @Test
+    public void shouldPersistWithRelativePath() {
+        final String graphLocation = "shouldPersistToGryoRelative.kryo";
+        final File f = new File(graphLocation);
+        if (f.exists() && f.isFile()) f.delete();
+
+        try {
+            final Configuration conf = new BaseConfiguration();
+            conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, 
"gryo");
+            conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, 
graphLocation);
+            final TinkerGraph graph = TinkerGraph.open(conf);
+            TinkerFactory.generateModern(graph);
+            graph.close();
+
+            final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
+            IoTest.assertModernGraph(reloadedGraph, true, false);
+            reloadedGraph.close();
+        } catch (Exception ex) {
+            if (f.exists() && f.isFile()) f.delete();
+        }
+    }
+
+    @Test
     public void shouldPersistToAnyGraphFormat() {
         final String graphLocation = 
TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + 
"shouldPersistToAnyGraphFormat.dat";
         final File f = new File(graphLocation);

Reply via email to