Source:
<code>public TaskStatus run(final TaskToolbox toolbox) throws Exception { final boolean determineIntervals = !ingestionSchema.getDataSchema() .getGranularitySpec() .bucketIntervals() .isPresent(); final FirehoseFactory delegateFirehoseFactory = ingestionSchema.getIOConfig().getFirehoseFactory(); final FirehoseFactory firehoseFactory = ingestionSchema.getIOConfig().isSkipFirehoseCaching() || delegateFirehoseFactory instanceof ReplayableFirehoseFactory ? delegateFirehoseFactory : new ReplayableFirehoseFactory( delegateFirehoseFactory, ingestionSchema.getTuningConfig().isReportParseExceptions(), null, null ); try { final Map<Interval, List<ShardSpec>> shardSpecs = determineShardSpecs(toolbox, firehoseFactory); final String version; final DataSchema dataSchema; if (!determineIntervals) { version = Iterables.getOnlyElement(getTaskLocks(toolbox)).getVersion(); dataSchema = ingestionSchema.getDataSchema(); } else { Interval interval = JodaUtils.umbrellaInterval(shardSpecs.keySet()); TaskLock lock = toolbox.getTaskActionClient().submit(new LockAcquireAction(interval)); version = lock.getVersion(); dataSchema = ingestionSchema.getDataSchema().withGranularitySpec( ingestionSchema.getDataSchema() .getGranularitySpec() .withIntervals( JodaUtils.condenseIntervals( shardSpecs.keySet() ) ) ); } if (generateAndPublishSegments(toolbox, dataSchema, shardSpecs, version, firehoseFactory)) { return TaskStatus.success(getId()); } else { return TaskStatus.failure(getId()); } } finally { <START> if (Closeable.class.isAssignableFrom(firehoseFactory.getClass())) { <END> try { ((Closeable) firehoseFactory).close(); } catch (Exception e) { log.error(e, "Exception while closing"); } } } }</code><technical_language>close firehose instead of factory</technical_language>

Target:
public TaskStatus run(final TaskToolbox toolbox) throws Exception { final boolean determineIntervals = !ingestionSchema.getDataSchema() .getGranularitySpec() .bucketIntervals() .isPresent(); final FirehoseFactory delegateFirehoseFactory = ingestionSchema.getIOConfig().getFirehoseFactory(); final FirehoseFactory firehoseFactory; if (ingestionSchema.getIOConfig().isSkipFirehoseCaching() || delegateFirehoseFactory instanceof ReplayableFirehoseFactory) { firehoseFactory = delegateFirehoseFactory; } else { firehoseFactory = new ReplayableFirehoseFactory( delegateFirehoseFactory, ingestionSchema.getTuningConfig().isReportParseExceptions(), null, null, smileMapper ); } final Map<Interval, List<ShardSpec>> shardSpecs = determineShardSpecs(toolbox, firehoseFactory); final String version; final DataSchema dataSchema; if (determineIntervals) { Interval interval = JodaUtils.umbrellaInterval(shardSpecs.keySet()); TaskLock lock = toolbox.getTaskActionClient().submit(new LockAcquireAction(interval)); version = lock.getVersion(); dataSchema = ingestionSchema.getDataSchema().withGranularitySpec( ingestionSchema.getDataSchema() .getGranularitySpec() .withIntervals( JodaUtils.condenseIntervals( shardSpecs.keySet() ) ) ); } else { version = Iterables.getOnlyElement(getTaskLocks(toolbox)).getVersion(); dataSchema = ingestionSchema.getDataSchema(); } if (generateAndPublishSegments(toolbox, dataSchema, shardSpecs, version, firehoseFactory)) { return TaskStatus.success(getId()); } else { return TaskStatus.failure(getId()); } }