Permalink
Browse files

Call close() on all (obvious) IndexHits instances to avoid resource l…

…eaks
  • Loading branch information...
1 parent 0689d08 commit 82c63a6b2482392b64764b601fb3b0014813d6a2 @ractive committed Dec 21, 2011
@@ -81,6 +81,8 @@ public void testPostEntityCreation() throws Exception {
assertEquals(node(subThing), subThingHits.getSingle());
assertEquals(thing.getClass().getName(), node(thing).getProperty(IndexingNodeTypeRepresentationStrategy.TYPE_PROPERTY_NAME));
assertEquals(subThing.getClass().getName(), node(subThing).getProperty(IndexingNodeTypeRepresentationStrategy.TYPE_PROPERTY_NAME));
+ thingHits.close();
+ subThingHits.close();
}
@Test
@@ -83,6 +83,7 @@ public void testPostEntityCreationOfRelationshipBacked() throws Exception {
Relationship rel = linkHits.getSingle();
assertEquals(rel(link), rel);
assertEquals(link.getClass().getName(), rel.getProperty("__type__"));
+ linkHits.close();
}
@Test
@@ -104,6 +105,7 @@ public void testPreEntityRemovalOfRelationshipBacked() throws Exception {
IndexHits<Relationship> linkHits = typesIndex.get(IndexingNodeTypeRepresentationStrategy.INDEX_KEY, link.getClass().getName());
assertNull(linkHits.getSingle());
+ linkHits.close();
}
@Test
@@ -64,6 +64,7 @@ public void createAndAssignState() {
final String foreignId = createForeignId(id);
IndexHits<Node> indexHits = getForeignIdIndex().get(FOREIGN_ID, foreignId);
Node node = indexHits.hasNext() ? indexHits.next() : null;
+ indexHits.close();
if (node == null) {
node = template.createNode();
persistForeignId(node, id);
@@ -37,6 +37,7 @@ public void testAddToNodeIndex() {
IndexHits<Node> hits = nodeIndex().get("name", "test");
Assert.assertEquals("index results", true, hits.hasNext());
Assert.assertEquals(node(), hits.next());
+ hits.close();
}
@Test
@@ -45,6 +46,7 @@ public void testAdvancedQuery() {
IndexHits<Node> hits = nodeIndex().query("name", "tes*");
Assert.assertEquals("index results", true, hits.hasNext());
Assert.assertEquals(node(), hits.next());
+ hits.close();
}
@Test
@@ -53,12 +55,14 @@ public void testRangeQuery() {
IndexHits<Node> hits = nodeIndex().query("age", "age:[30 TO 40]");
Assert.assertEquals("index results", true, hits.hasNext());
Assert.assertEquals(node(), hits.next());
+ hits.close();
}
@Test
public void testNotFoundInNodeIndex() {
IndexHits<Node> hits = nodeIndex().get("foo", "bar");
Assert.assertEquals("no index results", false, hits.hasNext());
+ hits.close();
}
@Test
@@ -68,12 +72,14 @@ public void testAddToRelationshipIndex() {
IndexHits<Relationship> hits = relationshipIndex().get("name", value);
Assert.assertEquals("index results", true, hits.hasNext());
Assert.assertEquals(relationship(), hits.next());
+ hits.close();
}
@Test
public void testNotFoundInRelationshipIndex() {
IndexHits<Relationship> hits = relationshipIndex().get("foo", "bar");
Assert.assertEquals("no index results", false, hits.hasNext());
+ hits.close();
}
@Test
@@ -86,6 +92,8 @@ public void testDeleteFromNodeIndex() {
nodeIndex().remove(node(), "time", value);
IndexHits<Node> hitsAfterRemove = nodeIndex().get("time", value);
Assert.assertEquals("not found in index results", false, hitsAfterRemove.hasNext());
+ hits.close();
+ hitsAfterRemove.close();
}
@Test
@@ -98,6 +106,8 @@ public void testDeleteFromRelationshipIndex() {
relationshipIndex().remove(relationship(), "time", value);
IndexHits<Relationship> hitsAfterRemove = relationshipIndex().get("time", value);
Assert.assertEquals("not found in index results", false, hitsAfterRemove.hasNext());
+ hits.close();
+ hitsAfterRemove.close();
}
private Index<Node> nodeIndex() {

0 comments on commit 82c63a6

Please sign in to comment.