Source:
<code>public RetryES(Forklift forklift, boolean ssl, String hostname, int port, boolean runRetries) { this.forklift = forklift; this.executor = Executors.newScheduledThreadPool(1); this.mapper = new ObjectMapper().registerModule(new JavaTimeModule()) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); final String prefix; if (ssl) prefix = "https://"; else prefix = "http://"; final JestClientFactory factory = new JestClientFactory(); factory.setHttpClientConfig( new HttpClientConfig.Builder(prefix + hostname + ":" + port) .multiThreaded(true) .build()); client = factory.getObject(); <START> cleanup = new Consumer<RetryMessage>() { <END> @Override public void accept(RetryMessage msg) { try { client.execute(new Delete.Builder(msg.getMessageId()).index("forklift-retry").type("msg").build()); } catch (IOException e) { log.error("Unable to cleanup retry: {}", msg.getMessageId(), e); } } }; if (runRetries) { try { final String query = "{\"size\" : \"10000\", \"query\" : { \"match_all\" : }}"; final Search search = new Search.Builder(query).addIndex("forklift-retry").build(); final SearchResult results = client.execute(search); if (results != null) { try { for (Hit<JsonObject, Void> msg : results.getHits(JsonObject.class)) { try { final RetryMessage retryMessage = mapper.readValue(msg.source.get("forklift-retry-msg").getAsString(), RetryMessage.class); log.info("Retrying: {}", retryMessage); executor.schedule(new RetryRunnable(retryMessage, forklift.getConnector(), cleanup), Long.parseLong(retryMessage.getProperties().get("forklift-retry-timeout")), TimeUnit.SECONDS); } catch (Exception e) { log.error("Unable to read result {}", msg.source); } } } catch (Exception e) { log.error("Search Results: {}", results.getJsonObject().toString()); log.error("", e); } } } catch (Exception e) { log.error("@trevor - don't ignore this!", e); } } }</code><technical_language>Nit: lambda</technical_language>

Target:
public RetryES(Forklift forklift, boolean ssl, String hostname, int port, boolean runRetries) { this.forklift = forklift; this.executor = Executors.newScheduledThreadPool(1); this.mapper = new ObjectMapper().registerModule(new JavaTimeModule()) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); final String prefix; if (ssl) prefix = "https://"; else prefix = "http://"; final JestClientFactory factory = new JestClientFactory(); factory.setHttpClientConfig( new HttpClientConfig.Builder(prefix + hostname + ":" + port) .multiThreaded(true) .build()); client = factory.getObject(); cleanup = (msg) -> { try { client.execute(new Delete.Builder(msg.getMessageId()).index("forklift-retry").type("msg").build()); } catch (IOException e) { log.error("Unable to cleanup retry: {}", msg.getMessageId(), e); } }; if (runRetries) { try { final String query = "{\"size\" : \"10000\", \"query\" : { \"match_all\" : }}"; final Search search = new Search.Builder(query).addIndex("forklift-retry").build(); final SearchResult results = client.execute(search); if (results != null) { try { for (Hit<JsonObject, Void> msg : results.getHits(JsonObject.class)) { try { final RetryMessage retryMessage = mapper.readValue(msg.source.get("forklift-retry-msg").getAsString(), RetryMessage.class); log.info("Retrying: {}", retryMessage); executor.schedule(new RetryRunnable(retryMessage, forklift.getConnector(), cleanup), Long.parseLong(retryMessage.getProperties().get("forklift-retry-timeout")), TimeUnit.SECONDS); } catch (Exception e) { log.error("Unable to read result {}", msg.source); } } } catch (Exception e) { log.error("Search Results: {}", results.getJsonObject().toString()); log.error("", e); } } } catch (Exception e) { log.error("@trevor - don't ignore this!", e); } } }