Browse Source

HDFS-10245. Fix the findbugs warnings in branch-2.7. Contributed by Brahma Reddy Battula.

Akira Ajisaka 9 years ago
parent
commit
076215024b

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

@@ -161,6 +161,9 @@ Release 2.7.3 - UNRELEASED
     HDFS-9555. LazyPersistFileScrubber should still sleep if there are errors
     in the clear progress (Phil Yang via kihwal)
 
+    HDFS-10245. Fix the findbugs warnings in branch-2.7.
+    (Brahma Reddy Battula via aajisaka)
+
 Release 2.7.2 - 2016-01-25
 
   INCOMPATIBLE CHANGES

+ 11 - 0
hadoop-hdfs-project/hadoop-hdfs/dev-support/findbugsExcludeFile.xml

@@ -82,6 +82,17 @@
        <Bug pattern="REC_CATCH_EXCEPTION" />
      </Match>
 
+    <!--
+     we don't need to synchronize out in newStreamForAppend method because
+     out.streamer cannot be touched by other threads. It is false-positive.
+    -->
+    <Match>
+        <Class name="org.apache.hadoop.hdfs.DFSOutputStream" />
+        <Method name="newStreamForAppend" />
+        <Field name="streamer" />
+        <Bug pattern="IS2_INCONSISTENT_SYNC" />
+    </Match>
+
      <!--
       lastAppliedTxid is carefully unsynchronized in the BackupNode in a couple spots.
       See the comments in BackupImage for justification.

+ 2 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java

@@ -2368,7 +2368,7 @@ public class DFSOutputStream extends FSOutputSummer
   }
 
   @VisibleForTesting
-  ExtendedBlock getBlock() {
+  synchronized ExtendedBlock getBlock() {
     return streamer.getBlock();
   }
 
@@ -2386,7 +2386,7 @@ public class DFSOutputStream extends FSOutputSummer
    * @return The times have retried to recover pipeline, for the same packet.
    */
   @VisibleForTesting
-  int getPipelineRecoveryCount() {
+  synchronized int getPipelineRecoveryCount() {
     return streamer.pipelineRecoveryCount;
   }
 }