diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Services.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/Services.java index c38bc12144..1e8d8fcb2e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Services.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Services.java @@ -54,6 +54,9 @@ public class Services implements Closeable { tagsManager = new TagsManager(caseDb); services.add(tagsManager); + //This lookup fails in the functional test code. See JIRA-4571 for details. + //For the time being, the closing of this service at line 108 will be made + //null safe so that the functional tests run with no issues. keywordSearchService = Lookup.getDefault().lookup(KeywordSearchService.class); services.add(keywordSearchService); @@ -105,7 +108,9 @@ public class Services implements Closeable { @Override public void close() throws IOException { for (Closeable service : services) { - service.close(); + if(service != null) { + service.close(); + } } } diff --git a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java index 68db7a36d7..8b55988fa7 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java +++ b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java @@ -706,6 +706,7 @@ class SevenZipExtractor { parentAr.addChild(child); depthMap.put(unpackedFile.getId(), child); } + unpackedFile.close(); } } catch (TskCoreException | NoCurrentCaseException e) { diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/CaseUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/CaseUtils.java index 81523c107d..a430a0a1be 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/CaseUtils.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/CaseUtils.java @@ -29,6 +29,7 @@ import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.CaseActionException; import org.sleuthkit.autopsy.casemodule.CaseDetails; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; +import org.sleuthkit.autopsy.coreutils.FileUtil; /** * Class with utility methods for opening and closing cases for functional @@ -52,13 +53,8 @@ public final class CaseUtils { */ Path caseDirectoryPath = Paths.get(System.getProperty("java.io.tmpdir"), caseName); File caseDirectory = caseDirectoryPath.toFile(); - if (caseDirectory.exists()) { - try { - FileUtils.deleteDirectory(caseDirectory); - } catch (IOException ex) { - Assert.fail(String.format("Failed to delete existing case %s at %s: %s", caseName, caseDirectoryPath, ex.getMessage())); - Exceptions.printStackTrace(ex); - } + if(caseDirectory.exists() && !FileUtil.deleteDir(caseDirectory)){ + Assert.fail(String.format("Failed to delete existing case %s at %s", caseName, caseDirectoryPath)); } /* @@ -96,15 +92,8 @@ public final class CaseUtils { String caseDirectory = currentCase.getCaseDirectory(); try { Case.closeCurrentCase(); - if (deleteCase) { - /* - * TODO (JIRA-4241): Restore the code to delete the case - * directory when the Image Gallery tool cleans up its drawable - * database connection deterministically, instead of in a - * finalizer. As it is now, case deletion can fail due to an - * open drawable database file handles. - */ - //FileUtils.deleteDirectory(caseDirectory); + if(deleteCase && !FileUtil.deleteDir(new File(caseDirectory))){ + Assert.fail(String.format("Failed to delete case directory for case %s at %s", caseName, caseDirectory)); } } catch (CaseActionException ex) { Exceptions.printStackTrace(ex); @@ -118,4 +107,4 @@ public final class CaseUtils { private CaseUtils() { } -} +} \ No newline at end of file