Skip to content

Commit a7f04d9

Browse files
authored
Closing RestRepository to avoid a connection leak (#1781)
This commit closes the RestRepository that is sent to the ScrollQuery constructor to avoid leaking connections to Elasticsearch when many fast scrolls are called in a tight loop. Closes #1212
1 parent f2f8caa commit a7f04d9

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

mr/src/main/java/org/elasticsearch/hadoop/rest/ScrollQuery.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public void close() {
7777
if (StringUtils.hasText(scrollId)) {
7878
repository.getRestClient().deleteScroll(scrollId);
7979
}
80+
repository.close();
8081
}
8182
}
8283

mr/src/test/java/org/elasticsearch/hadoop/rest/ScrollQueryTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void test() throws Exception {
5151
Assert.assertEquals("value", JsonUtils.query("field").apply(scrollQuery.next()[1]));
5252
Assert.assertFalse(scrollQuery.hasNext());
5353
scrollQuery.close();
54+
Mockito.verify(repository).close();
5455
Stats stats = scrollQuery.stats();
5556
Assert.assertEquals(1, stats.docsReceived);
5657
}

0 commit comments

Comments
 (0)