Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
defensive coding to prevent lost exceptions on tempfile cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
barmintor committed Apr 2, 2015
1 parent 0ff095f commit 632ba11
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,20 +423,20 @@ private File streamtoFile(InputStream objectAsStream)

FileOutputStream fos = new FileOutputStream(objectAsFile);
FileUtils.copy(objectAsStream, fos);
return objectAsFile;
} catch (IOException e) {
if (objectAsFile != null && objectAsFile.exists()) {
objectAsFile.delete();
}
throw e;
}
return objectAsFile;
}

// Distinguish temporary object files from real object files
// that were passed in for validation. This is a bit ugly as it stands,
// but it should only blow away files in the temp directory.
private void cleanUp(File f) {
if (f.getParentFile() != null) {
if (f != null && f.getParentFile() != null) {
if (m_absoluteTempPath.equalsIgnoreCase(f
.getParentFile().getAbsolutePath())) {
f.delete();
Expand Down

0 comments on commit 632ba11

Please sign in to comment.