HDFS-6902. FileWriter should be closed in finally block in BlockReceiver#receiveBlock() (Tsuyoshi OZAWA via Colin Patrick McCabe)

This commit is contained in:
Colin Patrick Mccabe 2014-08-27 13:49:31 -07:00
parent 225569ece2
commit b6b95ff667
2 changed files with 7 additions and 2 deletions

View File

@ -655,6 +655,9 @@ Release 2.6.0 - UNRELEASED
HDFS-6938. Cleanup javac warnings in FSNamesystem (Charles Lamb via wheat9)
HDFS-6902. FileWriter should be closed in finally block in
BlockReceiver#receiveBlock() (Tsuyoshi OZAWA via Colin Patrick McCabe)
Release 2.5.1 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -825,15 +825,17 @@ class BlockReceiver implements Closeable {
LOG.warn("Failed to delete restart meta file: " +
restartMeta.getPath());
}
FileWriter out = null;
try {
FileWriter out = new FileWriter(restartMeta);
out = new FileWriter(restartMeta);
// write out the current time.
out.write(Long.toString(Time.now() + restartBudget));
out.flush();
out.close();
} catch (IOException ioe) {
// The worst case is not recovering this RBW replica.
// Client will fall back to regular pipeline recovery.
} finally {
IOUtils.cleanup(LOG, out);
}
try {
// Even if the connection is closed after the ack packet is