diff --git a/Core/src/org/sleuthkit/autopsy/imagewriter/ImageWriter.java b/Core/src/org/sleuthkit/autopsy/imagewriter/ImageWriter.java index 3e44c4718a708fb765759af1787ebe3c0b0bc8b3..7a75e135176dab7637599bae3a9440adac1a4088 100644 --- a/Core/src/org/sleuthkit/autopsy/imagewriter/ImageWriter.java +++ b/Core/src/org/sleuthkit/autopsy/imagewriter/ImageWriter.java @@ -30,6 +30,7 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; import java.util.logging.Level; import org.netbeans.api.progress.ProgressHandle; import org.openide.util.NbBundle.Messages; @@ -143,6 +144,7 @@ public void propertyChange(PropertyChangeEvent evt) { }) private void startFinishImage(String dataSourceName) { + ExecutorService executor = Executors.newSingleThreadExecutor(); synchronized (currentTasksLock) { if (isCancelled) { return; @@ -186,7 +188,7 @@ private void startFinishImage(String dataSourceName) { // The added complexity here with the Future is because we absolutely need to make sure // the call to finishImageWriter returns before allowing the TSK data structures to be freed // during case close. - finishTask = Executors.newSingleThreadExecutor().submit(new Callable<Integer>() { + finishTask = executor.submit(new Callable<Integer>() { @Override public Integer call() throws TskCoreException { try { @@ -199,7 +201,7 @@ public Integer call() throws TskCoreException { caseDb.updateImagePath(settings.getPath(), dataSourceId); } return result; - } catch (TskCoreException ex) { + } catch (Throwable ex) { logger.log(Level.SEVERE, "Error finishing VHD image", ex); //NON-NLS return -1; } @@ -215,6 +217,7 @@ public Integer call() throws TskCoreException { try { // The call to get() can happen multiple times if the user closes the case, which is ok result = finishTask.get(); + executor.shutdownNow(); } catch (InterruptedException | ExecutionException ex) { logger.log(Level.SEVERE, "Error finishing VHD image", ex); //NON-NLS }