diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 16a194f8a9..655ec8ca12 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -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 diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java index 69ab68a529..f1724655ed 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java @@ -686,6 +686,7 @@ public abstract class Storage extends StorageInfo { * null 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) {