-
Notifications
You must be signed in to change notification settings - Fork 156
Closed
Labels
Description
With 1.0.0-M05, this exception is thrown
Exception in thread "main" java.lang.NullPointerException
at org.neo4j.driver.internal.InternalSession$2.run(InternalSession.java:140)
at org.neo4j.driver.internal.pool.PooledConnection.onDelegateException(PooledConnection.java:197)
at org.neo4j.driver.internal.pool.PooledConnection.receiveOne(PooledConnection.java:146)
at org.neo4j.driver.internal.InternalStatementResult.tryFetching(InternalStatementResult.java:344)
at org.neo4j.driver.internal.InternalStatementResult.hasNext(InternalStatementResult.java:190)
when you attempt to execute an invalid Cypher query using session.run. This only happens when a previous transaction has been carried out in the same session.
Session session = driver.session();
//Must have a transaction first
Transaction tx = session.beginTransaction();
StatementResult result = tx.run("CREATE (n) RETURN n");
if (result.hasNext()) {
result.next();
}
result.consume();
tx.success();
tx.close();
//Now the bad query
StatementResult badResult = session.run("CREAT (n) RETURN n");
if (badResult.hasNext()) {
badResult.next();
}
Without the previous tx
, badResult
is executed and produces
Exception in thread "main" org.neo4j.driver.v1.exceptions.ClientException: Invalid input ' ': expected 'e/E' (line 1, column 6 (offset: 5))
as expected.
If badResult
was a valid query badResult = session.run("CREATE (n) RETURN n");
then both execute fine.