Source:
public boolean checkIfTransactedRollbackPreservesOrder(long messagesPerRollback) throws FileNotFoundException { boolean result = true; int count = 0; Long messageIdentifier; int rollbackBatchIteration = 1; boolean isFirstMessageBatch = true; Map<Integer, Long> firstMessageBatch = new HashMap<Integer, Long>(); try { BufferedReader br = new BufferedReader(new FileReader(filePath)); try { String line = br.readLine(); while (line != null) { messageIdentifier = getMessageIdentifier(line); if (firstMessageBatch.containsValue(messageIdentifier)) { isFirstMessageBatch = false; if (count != messagesPerRollback * rollbackBatchIteration) { log.error("failed to check if rollback messages are received in order" + " to due to first duplicated message count " + count + " not equal to messages per each rollback." + messagesPerRollback + "."); result = false; } rollbackBatchIteration++; } if (isFirstMessageBatch) { firstMessageBatch.put(count, messageIdentifier); } if (!isFirstMessageBatch) { for (int i = 0; i < messagesPerRollback; i++) { messageIdentifier = getMessageIdentifier(line); if (null != firstMessageBatch.get(i)) { if (!firstMessageBatch.get(i).equals(messageIdentifier)) { result = false; log.error("Error in line :" + line + ".Rollback operation failed to keep message order."); } } line = br.readLine(); count++; } } if (isFirstMessageBatch) { line = br.readLine(); count++; } } } catch (IOException e) { log.error("Error while parsing the file containing received messages", e); } finally { try { br.close(); } catch (IOException e) { log.error("Error while closing the file containing received messages", e); } } } catch (FileNotFoundException e) { log.error("Error " + filePath + " the file containing received messages couldn't found", e); throw e; } AndesClientUtils.flushPrintWriters(); return result; }

Target:
public boolean checkIfTransactedRollbackPreservesOrder(long messagesPerRollback) throws FileNotFoundException { boolean result = true; int count = 0; Long messageIdentifier; int rollbackBatchIteration = 1; boolean isFirstMessageBatch = true; BufferedReader br = null; Map<Integer, Long> firstMessageBatch = new HashMap<Integer, Long>(); try { br = new BufferedReader(new FileReader(filePath)); String line = br.readLine(); while (line != null) { messageIdentifier = getMessageIdentifier(line); if (firstMessageBatch.containsValue(messageIdentifier)) { isFirstMessageBatch = false; if (count != messagesPerRollback * rollbackBatchIteration) { log.error("failed to check if rollback messages are received in order" + " to due to first duplicated message count " + count + " not equal to messages per each rollback." + messagesPerRollback + "."); result = false; } rollbackBatchIteration++; } if (isFirstMessageBatch) { firstMessageBatch.put(count, messageIdentifier); } if (!isFirstMessageBatch) { for (int i = 0; i < messagesPerRollback; i++) { messageIdentifier = getMessageIdentifier(line); if (null != firstMessageBatch.get(i)) { if (!firstMessageBatch.get(i).equals(messageIdentifier)) { result = false; log.error("Error in line :" + line + ".Rollback operation failed to keep message order."); } } line = br.readLine(); count++; } } if (isFirstMessageBatch) { line = br.readLine(); count++; } } } catch (FileNotFoundException e) { log.error("Error " + filePath + " the file containing received messages couldn't found", e); throw e; } catch (IOException e) { log.error("Error while parsing the file containing received messages", e); } finally { if (null != br) { IOUtils.closeQuietly(br); } } AndesClientUtils.flushPrintWriters(); return result; }