HDFS-12881. Output streams closed with IOUtils suppressing write errors. Contributed by Ajay Kumar
(cherry picked from commit 9ae8d1a8de2ffbc8a0082a0089f477d4cefea030)
This commit is contained in:
parent
6af3ea58c9
commit
605b8560f6
@ -1116,8 +1116,10 @@ static void computeChecksum(File srcMeta, File dstMeta,
|
||||
// calculate and write the last crc
|
||||
checksum.calculateChunkedSums(data, 0, offset, crcs, 0);
|
||||
metaOut.write(crcs, 0, 4);
|
||||
metaOut.close();
|
||||
metaOut = null;
|
||||
} finally {
|
||||
IOUtils.cleanupWithLogger(LOG, metaOut);
|
||||
IOUtils.closeStream(metaOut);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,8 @@ public static String getImageFileMD5IgnoringTxId(File imageFile)
|
||||
try {
|
||||
raf.seek(IMAGE_TXID_POS);
|
||||
raf.writeLong(0);
|
||||
raf.close();
|
||||
raf = null;
|
||||
} finally {
|
||||
IOUtils.closeStream(raf);
|
||||
}
|
||||
@ -542,9 +544,11 @@ public static void corruptVersionFile(File versionFile, String key, String value
|
||||
|
||||
out = new FileOutputStream(versionFile);
|
||||
props.store(out, null);
|
||||
|
||||
out.close();
|
||||
out = null;
|
||||
} finally {
|
||||
IOUtils.cleanup(null, fis, out);
|
||||
IOUtils.closeStream(fis);
|
||||
IOUtils.closeStream(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,9 +271,11 @@ private void copyPartOfFile(File src, File dest) throws IOException {
|
||||
in = new FileInputStream(src);
|
||||
out = new FileOutputStream(dest);
|
||||
in.getChannel().transferTo(0, MAX_BYTES, out.getChannel());
|
||||
out.close();
|
||||
out = null;
|
||||
} finally {
|
||||
IOUtils.cleanup(null, in);
|
||||
IOUtils.cleanup(null, out);
|
||||
IOUtils.closeStream(in);
|
||||
IOUtils.closeStream(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user