Subject: unit test freezing
Description: this patch should prevent test to remain running after error,
 applied upstream in master:
 https://github.com/broadinstitute/picard/commit/4c2e22a9c591b8b7e8a427d33478e43d45c113b5
--- a/src/main/java/picard/illumina/NewIlluminaBasecallsConverter.java
+++ b/src/main/java/picard/illumina/NewIlluminaBasecallsConverter.java
@@ -152,7 +152,7 @@
         completedWorkExecutor.shutdown();
 
         //thread by surface tile
-        final ThreadPoolExecutor tileProcessingExecutor = new ThreadPoolExecutorWithExceptions(numThreads);
+        final ThreadPoolExecutorWithExceptions tileProcessingExecutor = new ThreadPoolExecutorWithExceptions(numThreads);
 
         for (final Integer tile : tiles) {
             tileProcessingExecutor.submit(new TileProcessor(tile, barcodesFiles.get(tile)));
@@ -161,10 +161,18 @@
         tileProcessingExecutor.shutdown();
 
         awaitThreadPoolTermination("Reading executor", tileProcessingExecutor);
-        awaitThreadPoolTermination("Tile completion executor", completedWorkExecutor);
 
-        barcodeWriterThreads.values().forEach(ThreadPoolExecutor::shutdown);
-        barcodeWriterThreads.forEach((barcode, executor) -> awaitThreadPoolTermination(barcode + " writer", executor));
+        // if there was an exception reading then initiate an immediate shutdown.
+        if (tileProcessingExecutor.exception != null) {
+            int tasksStillRunning = completedWorkExecutor.shutdownNow().size();
+            tasksStillRunning += barcodeWriterThreads.values().stream().mapToLong(executor -> executor.shutdownNow().size()).sum();
+            throw new PicardException("Reading executor had exceptions. There were " + tasksStillRunning
+                    + " tasks were still running or queued and have been cancelled.", tileProcessingExecutor.exception);
+        } else {
+            awaitThreadPoolTermination("Tile completion executor", completedWorkExecutor);
+            barcodeWriterThreads.values().forEach(ThreadPoolExecutor::shutdown);
+            barcodeWriterThreads.forEach((barcode, executor) -> awaitThreadPoolTermination(barcode + " writer", executor));
+        }
     }
 
     private void awaitThreadPoolTermination(final String executorName, final ThreadPoolExecutor executorService) {
@@ -175,7 +183,7 @@
                         executorService.getQueue().size()));
             }
         } catch (final InterruptedException e) {
-            e.printStackTrace();
+            log.error("Interrupted exception caught: ", e);
         }
     }
 
@@ -278,12 +286,12 @@
             final int maxRecordsInRam =
                     Math.max(1, maxReadsInRamPerTile /
                             barcodeRecordWriterMap.size());
-            return SortingCollection.newInstance(
+            return SortingCollection.newInstanceFromPaths(
                     outputRecordClass,
                     codecPrototype.clone(),
                     outputRecordComparator,
                     maxRecordsInRam,
-                    tmpDirs);
+                    IOUtil.filesToPaths(tmpDirs));
         }
     }
 
--- a/src/main/java/picard/util/ThreadPoolExecutorWithExceptions.java
+++ b/src/main/java/picard/util/ThreadPoolExecutorWithExceptions.java
@@ -14,6 +14,7 @@
  * while executing
  */
 public class ThreadPoolExecutorWithExceptions extends ThreadPoolExecutor {
+    public Throwable exception = null;
     /**
      * Creates a fixed size thread pool executor that will rethrow exceptions from submitted jobs.
      *
@@ -40,6 +41,7 @@
             }
         }
         if (t != null) {
+            exception = t;
             throw new PicardException(t.getMessage(), t);
         }
     }
