Source:
<code>private static long importData( String title, int numRunners, InputIterable data, BatchingNeoStores stores, Supplier<EntityImporter> visitors, ExecutionMonitor executionMonitor, StatsProvider memoryStatsProvider ) throws IOException { LongAdder roughEntityCountProgress = new LongAdder(); ExecutorService pool = Executors.newFixedThreadPool( numRunners, new NamedThreadFactory( title + "Importer" ) ); IoMonitor writeMonitor = new IoMonitor( stores.getIoTracer() ); ControllableStep step = new ControllableStep( title, roughEntityCountProgress, Configuration.DEFAULT, writeMonitor, memoryStatsProvider ); StageExecution execution = new StageExecution( title, null, Configuration.DEFAULT, Collections.singletonList( step ), 0 ); <START> InputIterator dataIterator = data.iterator(); <END> for ( int i = 0; i < numRunners; i++ ) { pool.submit( new ExhaustingEntityImporterRunnable( execution, dataIterator, visitors.get(), roughEntityCountProgress ) ); } pool.shutdown(); executionMonitor.start( execution ); long startTime = currentTimeMillis(); long nextWait = 0; try { while ( !pool.awaitTermination( nextWait, TimeUnit.MILLISECONDS ) ) { executionMonitor.check( execution ); nextWait = executionMonitor.nextCheckTime() - currentTimeMillis(); } } catch ( InterruptedException e ) { Thread.currentThread().interrupt(); throw new IOException( e ); } execution.assertHealthy(); step.markAsCompleted(); writeMonitor.stop(); executionMonitor.end( execution, currentTimeMillis() - startTime ); return roughEntityCountProgress.sum(); }</code><technical_language>dataIterator closed of ExhaustingEntityImporterRunnables. closed numRunners times. I instead close this level, a try-with-resources spans executor shut down</technical_language>

Target:
private static long importData( String title, int numRunners, InputIterable data, BatchingNeoStores stores, Supplier<EntityImporter> visitors, ExecutionMonitor executionMonitor, StatsProvider memoryStatsProvider ) throws IOException { LongAdder roughEntityCountProgress = new LongAdder(); ExecutorService pool = Executors.newFixedThreadPool( numRunners, new NamedThreadFactory( title + "Importer" ) ); IoMonitor writeMonitor = new IoMonitor( stores.getIoTracer() ); ControllableStep step = new ControllableStep( title, roughEntityCountProgress, Configuration.DEFAULT, writeMonitor, memoryStatsProvider ); StageExecution execution = new StageExecution( title, null, Configuration.DEFAULT, Collections.singletonList( step ), 0 ); long startTime = currentTimeMillis(); try ( InputIterator dataIterator = data.iterator() ) { for ( int i = 0; i < numRunners; i++ ) { pool.submit( new ExhaustingEntityImporterRunnable( execution, dataIterator, visitors.get(), roughEntityCountProgress ) ); } pool.shutdown(); executionMonitor.start( execution ); long nextWait = 0; try { while ( !pool.awaitTermination( nextWait, TimeUnit.MILLISECONDS ) ) { executionMonitor.check( execution ); nextWait = executionMonitor.nextCheckTime() - currentTimeMillis(); } } catch ( InterruptedException e ) { Thread.currentThread().interrupt(); throw new IOException( e ); } } execution.assertHealthy(); step.markAsCompleted(); writeMonitor.stop(); executionMonitor.end( execution, currentTimeMillis() - startTime ); execution.assertHealthy(); return roughEntityCountProgress.sum(); }