Source:
public int run() throws IOException { Set<CoopLockRecord> lockedOperations = lockRecordsDao.getLockedOperations(bucketName); if (lockedOperations.isEmpty()) { logger.atInfo().log("No expired operation locks"); return 0; } Map<FileStatus, CoopLockRecord> expiredOperations = lockedOperations.stream() .map(this::getOperationLockIfExpiredUnchecked) .filter(Optional::isPresent) .map(Optional::get) .filter(operation -> !unlockOperationIfNoLogUnchecked(operation)) .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); if (CoopLockFsck.COMMAND_CHECK.equals(command)) { return 0; } if (!ARGUMENT_ALL_OPERATIONS.equals(fsckOperationId)) { Optional<Map.Entry<FileStatus, CoopLockRecord>> operationEntry = expiredOperations.entrySet().stream() .filter(e -> e.getValue().getOperationId().equals(fsckOperationId)) .findAny(); checkArgument(operationEntry.isPresent(), "%s operation not found", fsckOperationId); expiredOperations = ImmutableMap.of(operationEntry.get().getKey(), operationEntry.get().getValue()); } expiredOperations.forEach( (operationStatus, operationRecord) -> { long start = System.currentTimeMillis(); try { repairOperation(operationStatus, operationRecord); logger.atInfo().log( "Operation %s successfully %s in %dms", operationStatus.getPath(), COMMAND_ROLL_FORWARD.equals(command) ? "rolled forward" : "rolled back", System.currentTimeMillis() - start); } catch (Exception e) { logger.atSevere().withCause(e).log( "Operation %s failed to %s in %dms", operationStatus.getPath(), COMMAND_ROLL_FORWARD.equals(command) ? "roll forward" : "roll back", System.currentTimeMillis() - start); } }); return 0; }

Target:
public int run() throws IOException { Set<CoopLockRecord> lockedOperations = lockRecordsDao.getLockedOperations(bucketName); if (lockedOperations.isEmpty()) { logger.atInfo().log("No expired operation locks"); return 0; } Map<FileStatus, CoopLockRecord> expiredOperations = lockedOperations.stream() .map(this::getOperationLockIfExpired) .filter(Optional::isPresent) .map(Optional::get) .filter(this::checkLogExistsAndUnlockOtherwise) .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); if (CoopLockFsck.COMMAND_CHECK.equals(command)) { return 0; } if (!ARGUMENT_ALL_OPERATIONS.equals(fsckOperationId)) { Optional<Map.Entry<FileStatus, CoopLockRecord>> operationEntry = expiredOperations.entrySet().stream() .filter(e -> e.getValue().getOperationId().equals(fsckOperationId)) .findAny(); checkArgument(operationEntry.isPresent(), "%s operation not found", fsckOperationId); expiredOperations = ImmutableMap.of(operationEntry.get().getKey(), operationEntry.get().getValue()); } expiredOperations.forEach( (operationStatus, operationRecord) -> { long start = System.currentTimeMillis(); try { repairOperation(operationStatus, operationRecord); logger.atInfo().log( "Operation %s successfully %s in %dms", operationStatus.getPath(), COMMAND_ROLL_FORWARD.equals(command) ? "rolled forward" : "rolled back", System.currentTimeMillis() - start); } catch (Exception e) { logger.atSevere().withCause(e).log( "Operation %s failed to %s in %dms", operationStatus.getPath(), COMMAND_ROLL_FORWARD.equals(command) ? "roll forward" : "roll back", System.currentTimeMillis() - start); } }); return 0; }