Skip to content

NullPointerException at org.neo4j.driver.internal.InternalSession$2.run when an invalid Cypher query is executed #146

@luanne

Description

@luanne

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions