Skip to content
Snippets Groups Projects
Commit b9ac7a9d authored by Greg DiCristofaro's avatar Greg DiCristofaro
Browse files

shutdown thread executor and catch throwable

parent 6d78d25a
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment