@Test void cleanupWithIOException() throws IOException { when(restClient.clearScroll(any(), any())).thenThrow(new IOException()); ElasticsearchScrollRequest request = new ElasticsearchScrollRequest("test", factory); request.setScrollId("scroll123"); assertThrows(IllegalStateException.class, () -> client.cleanup(request)); }
@Override public void cleanup(ElasticsearchRequest request) { request.clean(scrollId -> { try { ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.addScrollId(scrollId); client.clearScroll(clearRequest, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to clean up resources for search request " + request, e); } }); }
ElasticsearchRestClient implements ElasticsearchClient { @Override public void cleanup(ElasticsearchRequest request) { request.clean(scrollId -> { try { ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.addScrollId(scrollId); client.clearScroll(clearRequest, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to clean up resources for search request " + request, e); } }); } }
ElasticsearchRestClient implements ElasticsearchClient { @Override public void cleanup(ElasticsearchRequest request) { request.clean(scrollId -> { try { ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.addScrollId(scrollId); client.clearScroll(clearRequest, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to clean up resources for search request " + request, e); } }); }  }
ElasticsearchRestClient implements ElasticsearchClient { @Override public void cleanup(ElasticsearchRequest request) { request.clean(scrollId -> { try { ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.addScrollId(scrollId); client.clearScroll(clearRequest, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to clean up resources for search request " + request, e); } }); }  @Override Map<String, IndexMapping> getIndexMappings(String indexExpression); @Override ElasticsearchResponse search(ElasticsearchRequest request); @Override void cleanup(ElasticsearchRequest request); @Override void schedule(Runnable task); }
ElasticsearchRestClient implements ElasticsearchClient { @Override public void cleanup(ElasticsearchRequest request) { request.clean(scrollId -> { try { ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.addScrollId(scrollId); client.clearScroll(clearRequest, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to clean up resources for search request " + request, e); } }); }  @Override Map<String, IndexMapping> getIndexMappings(String indexExpression); @Override ElasticsearchResponse search(ElasticsearchRequest request); @Override void cleanup(ElasticsearchRequest request); @Override void schedule(Runnable task);  }