Skip to content

Commit 56ad189

Browse files
author
mpv1989
committed
fixed NPE in ArangoCursor (issue #112)
1 parent ef11acd commit 56ad189

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ v4.1.11 (2017-03-xx)
55
* fixed exception handling in Connection (issue #110)
66
* added connection pooling (issue #103)
77
* extracted VelocyPack implementation to https://github.com/arangodb/java-velocypack
8+
* fixed NPE in ArangoCursor (issue #112)
89

910
v4.1.10 (2017-02-22)
1011
---------------------------

src/main/java/com/arangodb/ArangoCursor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ public boolean isCached() {
9797

9898
@Override
9999
public void close() throws IOException {
100-
execute.close(id);
100+
if (id != null) {
101+
execute.close(id);
102+
}
101103
}
102104

103105
@Override

src/test/java/com/arangodb/ArangoDatabaseTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,18 @@ public void queryClose() throws IOException {
534534

535535
}
536536

537+
@Test
538+
public void queryNoResults() throws IOException {
539+
try {
540+
db.createCollection(COLLECTION_NAME);
541+
final ArangoCursor<BaseDocument> cursor = db.query("FOR i IN @@col RETURN i",
542+
new MapBuilder().put("@col", COLLECTION_NAME).get(), null, BaseDocument.class);
543+
cursor.close();
544+
} finally {
545+
db.collection(COLLECTION_NAME).drop();
546+
}
547+
}
548+
537549
@Test
538550
public void explainQuery() {
539551
final AqlExecutionExplainEntity explain = arangoDB.db().explainQuery("for i in _apps return i", null, null);

0 commit comments

Comments
 (0)