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 2015/08/25 14:34:49 UTC

[30/50] incubator-tinkerpop git commit: Enforced rollback as default on Transaction.close(). TINKERPOP3-805

Enforced rollback as default on Transaction.close(). TINKERPOP3-805


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

Branch: refs/heads/tp30
Commit: 54b114bf6932503026ce777576255d817ef9118e
Parents: fa95c41
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Aug 17 16:45:35 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 17 16:45:35 2015 -0400

----------------------------------------------------------------------
 .../gremlin/structure/util/AbstractTransaction.java    |  4 ++--
 .../tinkerpop/gremlin/structure/TransactionTest.java   | 13 +++++++------
 2 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/54b114bf/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
index 4d15a45..26a7d78 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
@@ -55,8 +55,8 @@ public abstract class AbstractTransaction implements Transaction {
         // auto transaction behavior
         readWriteConsumer = READ_WRITE_BEHAVIOR.AUTO;
 
-        // commit on close
-        closeConsumer = CLOSE_BEHAVIOR.COMMIT;
+        // default is to rollback transactions on close
+        closeConsumer = CLOSE_BEHAVIOR.ROLLBACK;
 
         this.g = g;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/54b114bf/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/TransactionTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/TransactionTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/TransactionTest.java
index 5736be8..2395d9a 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/TransactionTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/TransactionTest.java
@@ -357,10 +357,11 @@ public class TransactionTest extends AbstractGremlinTest {
     @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
     @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
     @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_PERSISTENCE)
-    public void shouldCommitOnCloseByDefault() throws Exception {
+    public void shouldCommitOnCloseWhenConfigured() throws Exception {
         final AtomicReference<Object> oid = new AtomicReference<>();
         final Thread t = new Thread(() -> {
             final Vertex v1 = graph.addVertex("name", "marko");
+            g.tx().onClose(Transaction.CLOSE_BEHAVIOR.COMMIT);
             oid.set(v1.id());
             graph.tx().close();
         });
@@ -375,17 +376,17 @@ public class TransactionTest extends AbstractGremlinTest {
     @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
     @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
     @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_PERSISTENCE)
-    public void shouldRollbackOnCloseWhenConfigured() throws Exception {
+    public void shouldRollbackOnCloseByDefault() throws Exception {
         final AtomicReference<Object> oid = new AtomicReference<>();
         final AtomicReference<Vertex> vid = new AtomicReference<>();
         final Thread t = new Thread(() -> {
             vid.set(graph.addVertex("name", "stephen"));
             graph.tx().commit();
 
-            final Vertex v1 = graph.addVertex("name", "marko");
-            oid.set(v1.id());
-            g.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK);
-            graph.tx().close();
+            try (Transaction ignored = graph.tx()) {
+                final Vertex v1 = graph.addVertex("name", "marko");
+                oid.set(v1.id());
+            }
         });
         t.start();
         t.join();