Source:
<code>public void updateState(List<TridentTuple> tuples, TridentCollector collector) { String topic = null; try { final long startTime = System.currentTimeMillis(); int numberOfRecords = tuples.size(); List<Future<RecordMetadata>> futures = new ArrayList<>(numberOfRecords); for (TridentTuple tuple : tuples) { topic = topicSelector.getTopic(tuple); V messageFromTuple = mapper.getMessageFromTuple(tuple); K keyFromTuple = mapper.getKeyFromTuple(tuple); if (topic != null) { if (messageFromTuple != null) { <START> Future<RecordMetadata> result = producer.send(new ProducerRecord<K, V>(topic, keyFromTuple, messageFromTuple)); <END> futures.add(result); } else { LOG.warn("skipping Message with Key as message was null", keyFromTuple); } } else { LOG.warn("skipping key = {}, topic selector returned null.", keyFromTuple); } } int emittedRecords = futures.size(); List<ExecutionException> exceptions = new ArrayList<>(emittedRecords); for (Future<RecordMetadata> future : futures) { try { future.get(); } catch (ExecutionException e) { exceptions.add(e); } } if (exceptions.size() > 0) { StringBuilder errorMsg = new StringBuilder("Could not retrieve result for messages "); errorMsg.append(tuples).append(" from topic = ").append(topic) .append(" because of the following exceptions:").append(System.lineSeparator()); for (ExecutionException exception : exceptions) { errorMsg = errorMsg.append(exception.getMessage()).append(System.lineSeparator());; } String message = errorMsg.toString(); LOG.error(message); throw new FailedException(message); } long latestTime = System.currentTimeMillis(); LOG.info("Emitted record sucessfully in ms to topic ", emittedRecords, latestTime - startTime, topic); } catch (Exception ex) { String errorMsg = "Could not send messages " + tuples + " to topic = " + topic; LOG.warn(errorMsg, ex); throw new FailedException(errorMsg, ex); } }</code><technical_language>Pretty <> work</technical_language>

Target:
public void updateState(List<TridentTuple> tuples, TridentCollector collector) { String topic = null; try { final long startTime = System.currentTimeMillis(); int numberOfRecords = tuples.size(); List<Future<RecordMetadata>> futures = new ArrayList<>(numberOfRecords); for (TridentTuple tuple : tuples) { topic = topicSelector.getTopic(tuple); V messageFromTuple = mapper.getMessageFromTuple(tuple); K keyFromTuple = mapper.getKeyFromTuple(tuple); if (topic != null) { if (messageFromTuple != null) { Future<RecordMetadata> result = producer.send(new ProducerRecord<>(topic, keyFromTuple, messageFromTuple)); futures.add(result); } else { LOG.warn("skipping Message with Key as message was null", keyFromTuple); } } else { LOG.warn("skipping key = {}, topic selector returned null.", keyFromTuple); } } int emittedRecords = futures.size(); List<ExecutionException> exceptions = new ArrayList<>(emittedRecords); for (Future<RecordMetadata> future : futures) { try { future.get(); } catch (ExecutionException e) { exceptions.add(e); } } if (exceptions.size() > 0) { StringBuilder errorMsg = new StringBuilder("Could not retrieve result for messages "); errorMsg.append(tuples).append(" from topic = ").append(topic) .append(" because of the following exceptions:").append(System.lineSeparator()); for (ExecutionException exception : exceptions) { errorMsg = errorMsg.append(exception.getMessage()).append(System.lineSeparator()); } String message = errorMsg.toString(); LOG.error(message); throw new FailedException(message); } long latestTime = System.currentTimeMillis(); LOG.info("Emitted record sucessfully in ms to topic ", emittedRecords, latestTime - startTime, topic); } catch (Exception ex) { String errorMsg = "Could not send messages " + tuples + " to topic = " + topic; LOG.warn(errorMsg, ex); throw new FailedException(errorMsg, ex); } }