ソースを参照

Merge 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/branches/branch-2@1586393 13f79535-47bb-0310-9956-ffa450edef68
Uma Maheswara Rao G 11 年 前
コミット
2dea526b23

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -82,6 +82,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

+ 4 - 0
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 {
      * <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) {