Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Fixes #681 correct transaction handling behavior in cypher fo…

…r nested tx in updating operations"

This reverts commit 43150be.
  • Loading branch information...
commit a9021e568a9242bf75956b3dc44006bf138e4db9 1 parent d09769f
@systay authored
View
13 cypher/src/main/scala/org/neo4j/cypher/EagerPipeExecutionResult.scala
@@ -21,7 +21,7 @@ package org.neo4j.cypher
import internal.pipes.QueryState
import internal.symbols.SymbolTable
-import org.neo4j.graphdb.{Transaction, GraphDatabaseService}
+import org.neo4j.graphdb.GraphDatabaseService
import org.neo4j.kernel.GraphDatabaseAPI
import collection.Map
@@ -44,9 +44,14 @@ class EagerPipeExecutionResult(r: => Traversable[Map[String, Any]],
val eagerResult = try {
immutableResult.toList
} catch {
- case e =>
- state.transaction.foreach(tx => tx.failure())
- throw e
+ case e => db match {
+ case adb: GraphDatabaseAPI => adb.getTxManager.getTransaction match {
+ case null => throw e
+ case tx => tx.rollback()
+ throw e
+ }
+ case _ => throw e
+ }
}
val ms = System.currentTimeMillis() - start
View
14 cypher/src/test/scala/org/neo4j/cypher/MutatingIntegrationTests.scala
@@ -23,7 +23,7 @@ import org.junit.Test
import org.junit.Assert._
import collection.JavaConverters._
import org.scalatest.Assertions
-import org.neo4j.graphdb._
+import org.neo4j.graphdb.{Path, NotFoundException, Relationship, Node}
import java.util.HashMap
class MutatingIntegrationTests extends ExecutionEngineHelper with Assertions with StatisticsChecker {
@@ -468,18 +468,8 @@ return distinct center""")
assert(result.startNode() === a)
assert(result.endNode() === b)
}
-
- @Test
- def failure_only_fails_inner_transaction() {
- val tx = graph.beginTx()
- try {
- parseAndExecute("start a=node({id}) set a.foo = 'bar' return a","id"->"0")
- } catch {
- case _ => tx.failure()
- }
- finally tx.finish()
- }
}
+
trait StatisticsChecker extends Assertions {
def assertStats(result: ExecutionResult,
nodesCreated: Long = 0,
View
60 server/src/functionaltest/java/org/neo4j/server/rest/BatchOperationFunctionalTest.java
@@ -23,18 +23,13 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-import static org.neo4j.helpers.collection.MapUtil.map;
import java.util.List;
import java.util.Map;
-import junit.framework.Assert;
import org.json.JSONException;
import org.junit.Test;
-import org.neo4j.cypher.ParameterWrongTypeException;
-import org.neo4j.cypher.javacompat.ExecutionEngine;
import org.neo4j.graphdb.Node;
-import org.neo4j.graphdb.Transaction;
import org.neo4j.kernel.impl.annotations.Documented;
import org.neo4j.server.rest.domain.JsonHelper;
import org.neo4j.server.rest.domain.JsonParseException;
@@ -43,7 +38,6 @@
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.UniformInterfaceException;
-import org.neo4j.test.ImpermanentGraphDatabase;
public class BatchOperationFunctionalTest extends AbstractRestFunctionalTestBase
{
@@ -358,59 +352,7 @@ public void shouldHandleUnicodeGetCorrectly() throws Exception {
// Ensure nothing was borked.
assertThat(returnedValue, is(complicatedString));
}
-
- @Test
- public void testInvalidCypher() throws Exception {
- ImpermanentGraphDatabase gdb = new ImpermanentGraphDatabase();
- Transaction tx = gdb.beginTx();
- try {
- ExecutionEngine engine = new ExecutionEngine(gdb);
- engine.execute("start n=node({id}) set n.foo = 10 return n", map("id", "0"));
- tx.success();
- Assert.fail("Should fail with ParameterWrongTypeException");
- } catch (ParameterWrongTypeException e) {
- tx.failure();
- Assert.assertEquals("Expected a propertycontainer or number here, but got: 0",e.getMessage());
- } finally {
- tx.success();
- }
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void shouldHandleFailingCypherStatementCorrectly() throws Exception {
- String jsonString = new PrettyJSON()
- .array()
- .object()
- .key("method") .value("POST")
- .key("to") .value("/cypher")
- .key("body") .object()
- .key("query").value("start n=node({id}) set n.foo = 10 return n")
- .key("params").object().key("id").value("0").endObject()
- .endObject()
- .endObject()
- .object()
- .key("method") .value("POST")
- .key("to") .value("/node")
- .endObject()
- .endArray()
- .toString();
-
- String entity = gen.get()
- .expectedStatus( 500 )
- .payload( jsonString )
- .post( batchUri() )
- .entity();
-
- System.out.println("entity = " + entity);
- // Pull out the property value from the depths of the response
- Map<String, Object> result = JsonHelper.jsonToMap(entity);
- String exception = (String) result.get("exception");
- assertThat(exception, is("BatchOperationFailedException"));
- String innerException = (String) ((Map) JsonHelper.jsonToMap((String) result.get("message"))).get("exception");
- assertThat(innerException, is("ParameterWrongTypeException"));
- }
-
+
@Test
@Graph("Peter likes Jazz")
public void shouldHandleEscapedStrings() throws ClientHandlerException,
View
30 shell/src/test/java/org/neo4j/shell/TestApps.java
@@ -19,34 +19,25 @@
*/
package org.neo4j.shell;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.neo4j.graphdb.DynamicRelationshipType.withName;
-
-import java.io.File;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.regex.Pattern;
-
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.cypher.NodeStillHasRelationshipsException;
-import org.neo4j.graphdb.Direction;
-import org.neo4j.graphdb.DynamicRelationshipType;
-import org.neo4j.graphdb.Node;
-import org.neo4j.graphdb.Relationship;
-import org.neo4j.graphdb.RelationshipType;
-import org.neo4j.graphdb.Transaction;
+import org.neo4j.graphdb.*;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.collection.MapUtil;
import org.neo4j.kernel.GraphDatabaseAPI;
import org.neo4j.kernel.impl.util.FileUtils;
import org.neo4j.shell.kernel.GraphDatabaseShellServer;
+import java.io.File;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import static org.junit.Assert.*;
+import static org.neo4j.graphdb.DynamicRelationshipType.withName;
+
public class TestApps extends AbstractShellTest
{
@Test
@@ -381,6 +372,7 @@ public void cypherNodeStillHasRelationshipsException() throws Exception
}
catch ( ShellException e )
{
+ System.out.println(e);
assertTrue( "Expected notice about cause not found in " + e.getMessage(),
e.getMessage().contains( NodeStillHasRelationshipsException.class.getSimpleName() ) );
}
Please sign in to comment.
Something went wrong with that request. Please try again.