Source:
<code>public TaskStatus run(TaskToolbox toolbox) throws Exception { final TaskLock myLock = Iterables.getOnlyElement(getTaskLocks(toolbox)); if (!myLock.getDataSource().equals(getDataSource())) { throw new ISE("WTF?! Lock dataSource[%s] != task dataSource[%s]", myLock.getDataSource(), getDataSource()); } if (!myLock.getInterval().equals(getInterval())) { throw new ISE("WTF?! Lock interval[%s] != task interval[%s]", myLock.getInterval(), getInterval()); } final List<DataSegment> unusedSegments = toolbox .getTaskActionClient() .submit(new SegmentListUnusedAction(myLock.getDataSource(), myLock.getInterval())); for (final DataSegment unusedSegment : unusedSegments) { if (unusedSegment.getVersion().compareTo(myLock.getVersion()) > 0) { throw new ISE( "WTF?! Unused segment[%s] has version[%s] > task version[%s]", unusedSegment.getIdentifier(), unusedSegment.getVersion(), myLock.getVersion() ); } log.info("OK to restore segment: %s", unusedSegment.getIdentifier()); } <START> List<DataSegment> restoredSegments = Lists.newLinkedList(); <END> for (DataSegment segment : unusedSegments) { final DataSegment restored = toolbox.getDataSegmentArchiver().restore(segment); if (restored == null) { log.info("Segment [%s] did not move, not updating metadata", segment); } else { restoredSegments.add(toolbox.getDataSegmentArchiver().restore(segment)); } } if (restoredSegments.isEmpty()) { log.info("No segments restored"); } else { toolbox.getTaskActionClient().submit( new SegmentMetadataUpdateAction( ImmutableSet.copyOf(restoredSegments) ) ); } return TaskStatus.success(getId()); }</code><technical_language>I LinkedList is pointless here. a performance-critical place; a reason LinkedList default ArrayList. reader sees LinkedList, spends mental cycles understand, is here. confusing is apparent reason</technical_language>

Target:
public TaskStatus run(TaskToolbox toolbox) throws Exception { final TaskLock myLock = Iterables.getOnlyElement(getTaskLocks(toolbox)); if (!myLock.getDataSource().equals(getDataSource())) { throw new ISE("WTF?! Lock dataSource[%s] != task dataSource[%s]", myLock.getDataSource(), getDataSource()); } if (!myLock.getInterval().equals(getInterval())) { throw new ISE("WTF?! Lock interval[%s] != task interval[%s]", myLock.getInterval(), getInterval()); } final List<DataSegment> unusedSegments = toolbox .getTaskActionClient() .submit(new SegmentListUnusedAction(myLock.getDataSource(), myLock.getInterval())); for (final DataSegment unusedSegment : unusedSegments) { if (unusedSegment.getVersion().compareTo(myLock.getVersion()) > 0) { throw new ISE( "WTF?! Unused segment[%s] has version[%s] > task version[%s]", unusedSegment.getIdentifier(), unusedSegment.getVersion(), myLock.getVersion() ); } log.info("OK to restore segment: %s", unusedSegment.getIdentifier()); } final List<DataSegment> restoredSegments = new ArrayList<>(); for (DataSegment segment : unusedSegments) { final DataSegment restored = toolbox.getDataSegmentArchiver().restore(segment); if (restored != null) { restoredSegments.add(restored); } else { log.info("Segment [%s] did not move, not updating metadata", segment); } } if (restoredSegments.isEmpty()) { log.info("No segments restored"); } else { toolbox.getTaskActionClient().submit( new SegmentMetadataUpdateAction( ImmutableSet.copyOf(restoredSegments) ) ); } return TaskStatus.success(getId()); }