Skip to content

ArangoCursor throws NPE when closed and no records returned  #112

Closed
@virmundi

Description

@virmundi

When I run a query that returns 0 results, the ArangoCursor throws a NPE when closing.

	try (ArangoCursor<BaseDocument> cursor = dbContext.db.query(MIGRATION_APPLIED_QUERY,
			params,
			null,
			BaseDocument.class) ) {
		
		
		countSize = cursor.hasNext() ? -1 : 0;
	} catch ( IOException e ) {
		throw new IllegalArgumentException("Couldn't find migration status for " + migrationName, e);
	} catch (NullPointerException npe) {
		System.err.println("Probably ok. Bug in ArangoDB driver for auto closed cursors.");
		npe.printStackTrace();
	}

Here's the stack

java.lang.IllegalArgumentException: Couldn't find migration status for 2
	at com.deusdatsolutions.migrantverde.Migrator.notApplied(Migrator.java:181)
	at com.deusdatsolutions.migrantverde.Migrator.migrate(Migrator.java:106)
	at com.deusdatsolutions.migrantverde.MigratorIT.a(MigratorIT.java:99)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.NullPointerException
	at com.arangodb.internal.ArangoExecutor.createPath(ArangoExecutor.java:92)
	at com.arangodb.internal.InternalArangoDatabase.queryCloseRequest(InternalArangoDatabase.java:156)
	at com.arangodb.ArangoDatabase.access$200(ArangoDatabase.java:67)
	at com.arangodb.ArangoDatabase$1.close(ArangoDatabase.java:250)
	at com.arangodb.ArangoCursor.close(ArangoCursor.java:100)
	at com.deusdatsolutions.migrantverde.Migrator.notApplied(Migrator.java:180)
	... 26 more

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions