Skip to content

Commit

Permalink
try-with-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
ErykKul committed Nov 10, 2023
1 parent 50c3620 commit 7715ff9
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1504,20 +1504,12 @@ public static void validateDataFileChecksum(DataFile dataFile) throws IOExceptio
boolean fixed = false;
if (!dataFile.isTabularData() && dataFile.getIngestReport() != null) {
// try again, see if the .orig file happens to be there:
InputStream in = null;
try {
in = storage.getAuxFileAsInputStream(FileUtil.SAVED_ORIGINAL_FILENAME_EXTENSION);
} catch (IOException ioex) {
in = null;
try (InputStream in = storage.getAuxFileAsInputStream(FileUtil.SAVED_ORIGINAL_FILENAME_EXTENSION)) {
recalculatedChecksum = FileUtil.calculateChecksum(in, checksumType);
} catch (RuntimeException rte) {
recalculatedChecksum = null;
}
if (in != null) {
try {
recalculatedChecksum = FileUtil.calculateChecksum(in, checksumType);
} catch (RuntimeException rte) {
recalculatedChecksum = null;
} finally {
IOUtils.closeQuietly(in);
}
if (recalculatedChecksum != null) {
// try again:
if (recalculatedChecksum.equals(dataFile.getChecksumValue())) {
fixed = true;
Expand Down

0 comments on commit 7715ff9

Please sign in to comment.