Source:
Pair<String, String> doWork(Map<String, String> statsWrappersJSON) throws IOException { StatsSnapshot partitionSnapshot = new StatsSnapshot(0L, new HashMap<String, StatsSnapshot>()); Map<String, Long> partitionTimestampMap = new HashMap<>(); StatsSnapshot rawPartitionSnapshot = new StatsSnapshot(0L, new HashMap<String, StatsSnapshot>()); for (Map.Entry<String, String> statsWrapperJSON : statsWrappersJSON.entrySet()) { if (statsWrapperJSON != null && statsWrapperJSON.getValue() != null) { try { StatsWrapper snapshotWrapper = mapper.readValue(statsWrapperJSON.getValue(), StatsWrapper.class); StatsWrapper snapshotWrapperCopy = mapper.readValue(statsWrapperJSON.getValue(), StatsWrapper.class); combineRaw(rawPartitionSnapshot, snapshotWrapper); combine(partitionSnapshot, snapshotWrapperCopy, statsWrapperJSON.getKey(), partitionTimestampMap); } catch (Exception e) { logger.error("Exception occurred while processing stats from with the error message: {}", statsWrapperJSON.getKey(), e); } } } if (logger.isTraceEnabled()) { logger.trace("Combined raw snapshot {}", mapper.writeValueAsString(rawPartitionSnapshot)); logger.trace("Combined snapshot {}", mapper.writeValueAsString(partitionSnapshot)); } StatsSnapshot reducedRawSnapshot = reduce(rawPartitionSnapshot); StatsSnapshot reducedSnapshot = reduce(partitionSnapshot); if (logger.isTraceEnabled()) { logger.trace("Reduced raw snapshot {}", mapper.writeValueAsString(reducedRawSnapshot)); logger.trace("Reduced snapshot {}", mapper.writeValueAsString(reducedSnapshot)); } return new Pair<>(mapper.writeValueAsString(reducedRawSnapshot), mapper.writeValueAsString(reducedSnapshot)); }

Target:
Pair<String, String> doWork(Map<String, String> statsWrappersJSON) throws IOException { StatsSnapshot partitionSnapshot = new StatsSnapshot(0L, new HashMap<String, StatsSnapshot>()); Map<String, Long> partitionTimestampMap = new HashMap<>(); StatsSnapshot rawPartitionSnapshot = new StatsSnapshot(0L, new HashMap<String, StatsSnapshot>()); for (Map.Entry<String, String> statsWrapperJSON : statsWrappersJSON.entrySet()) { if (statsWrapperJSON != null && statsWrapperJSON.getValue() != null) { try { StatsWrapper snapshotWrapper = mapper.readValue(statsWrapperJSON.getValue(), StatsWrapper.class); StatsWrapper snapshotWrapperCopy = mapper.readValue(statsWrapperJSON.getValue(), StatsWrapper.class); combineRaw(rawPartitionSnapshot, snapshotWrapper); combine(partitionSnapshot, snapshotWrapperCopy, statsWrapperJSON.getKey(), partitionTimestampMap); } catch (Exception e) { logger.error("Exception occurred while processing stats from {}", statsWrapperJSON.getKey(), e); } } } if (logger.isTraceEnabled()) { logger.trace("Combined raw snapshot {}", mapper.writeValueAsString(rawPartitionSnapshot)); logger.trace("Combined snapshot {}", mapper.writeValueAsString(partitionSnapshot)); } StatsSnapshot reducedRawSnapshot = reduce(rawPartitionSnapshot); StatsSnapshot reducedSnapshot = reduce(partitionSnapshot); if (logger.isTraceEnabled()) { logger.trace("Reduced raw snapshot {}", mapper.writeValueAsString(reducedRawSnapshot)); logger.trace("Reduced snapshot {}", mapper.writeValueAsString(reducedSnapshot)); } return new Pair<>(mapper.writeValueAsString(reducedRawSnapshot), mapper.writeValueAsString(reducedSnapshot)); }