Skip to content

Commit 9502967

Browse files
committed
ensure temp file cleanup
1 parent 6274ecc commit 9502967

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

core/src/main/java/com/bc/fiduceo/util/TempFileUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ public File createDir(String directoryName) throws IOException {
7070
}
7171

7272
public void delete(File tempFile) {
73-
deleteFileIfExists(tempFile);
73+
final boolean deleted = deleteFileIfExists(tempFile);
7474

75-
tempFileList.remove(tempFile);
75+
if (deleted) {
76+
tempFileList.remove(tempFile);
77+
}
7678
}
7779

7880
public void cleanup() {
@@ -85,17 +87,21 @@ public void cleanup() {
8587
}
8688
}
8789

88-
private void deleteFileIfExists(File tempFile) {
90+
private boolean deleteFileIfExists(File tempFile) {
91+
boolean success = true;
8992
if (tempFile.isFile()) {
9093
if (!tempFile.delete()) {
9194
FiduceoLogger.getLogger().warning("Unable to delete file: " + tempFile.getAbsolutePath());
95+
success = false;
9296
}
9397
}
9498
if (tempFile.isDirectory()) {
9599
if (!FileUtils.deleteTree(tempFile)) {
96100
FiduceoLogger.getLogger().warning("Unable to delete directory: " + tempFile.getAbsolutePath());
101+
success = false;
97102
}
98103
}
104+
return success;
99105
}
100106

101107
public void keepAfterCleanup(boolean keep) {

matchup-tool/src/main/java/com/bc/fiduceo/matchup/strategy/InsituPolarOrbitingMatchupStrategy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ public MatchupCollection createMatchupCollection(ToolContext context) throws SQL
178178
applyConditionsAndScreenings(matchupSet, conditionEngine, conditionEngineContext, screeningEngine, primaryReader, secondaryReaders);
179179
}
180180

181+
readerCache.close();
182+
181183
return combineBean.matchupCollection;
182184
}
183185

0 commit comments

Comments
 (0)