HDFS-5669. Storage#tryLock() should check for null before logging successfull message. Contributed by Vinayakumar B

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1586392 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uma Maheswara Rao G 2014-04-10 18:11:28 +00:00
parent 8c19d0bb7a
commit af0fe05a92
2 changed files with 7 additions and 0 deletions

View File

@ -332,6 +332,9 @@ Release 2.5.0 - UNRELEASED
HDFS-6160. TestSafeMode occasionally fails. (Arpit Agarwal)
HDFS-5669. Storage#tryLock() should check for null before logging successfull message
(Vinayakumar B via umamahesh)
Release 2.4.1 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -686,6 +686,7 @@ public abstract class Storage extends StorageInfo {
* <code>null</code> if storage is already locked.
* @throws IOException if locking fails.
*/
@SuppressWarnings("resource")
FileLock tryLock() throws IOException {
boolean deletionHookAdded = false;
File lockF = new File(root, STORAGE_FILE_LOCK);
@ -698,6 +699,9 @@ public abstract class Storage extends StorageInfo {
FileLock res = null;
try {
res = file.getChannel().tryLock();
if (null == res) {
throw new OverlappingFileLockException();
}
file.write(jvmName.getBytes(Charsets.UTF_8));
LOG.info("Lock on " + lockF + " acquired by nodename " + jvmName);
} catch(OverlappingFileLockException oe) {