Browse Source

HADOOP-12378. Fix findbugs warnings in hadoop-tools module. Contributed by Akira AJISAKA.

(cherry picked from commit ef0870ad038a1b72ea14ce550e34139b81eb901b)
Masatake Iwasaki 9 năm trước cách đây
mục cha
commit
ff233dfca0

+ 7 - 2
hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/DfsTask.java

@@ -21,6 +21,7 @@ package org.apache.hadoop.ant;
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.LinkedList;
@@ -146,8 +147,12 @@ public class DfsTask extends Task {
   protected void pushContext() {
     antOut = System.out;
     antErr = System.err;
-    System.setOut(new PrintStream(out));
-    System.setErr(out == err ? System.out : new PrintStream(err));
+    try {
+      System.setOut(new PrintStream(out, false, "UTF-8"));
+      System.setErr(out == err ?
+          System.out : new PrintStream(err, false, "UTF-8"));
+    } catch (UnsupportedEncodingException ignored) {
+    }
   }
 
   /**

+ 1 - 1
hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsExists.java

@@ -19,6 +19,6 @@
 package org.apache.hadoop.ant.condition;
 
 public class DfsExists extends DfsBaseConditional {
-  protected final char flag = 'e';
+  protected static final char flag = 'e';
   protected char getFlag() { return flag; }
 }

+ 1 - 1
hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsIsDir.java

@@ -19,6 +19,6 @@
 package org.apache.hadoop.ant.condition;
 
 public class DfsIsDir extends DfsBaseConditional {
-  protected final char flag = 'd';
+  protected static final char flag = 'd';
   protected char getFlag() { return flag; }
 }

+ 1 - 1
hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsZeroLen.java

@@ -19,6 +19,6 @@
 package org.apache.hadoop.ant.condition;
 
 public class DfsZeroLen extends DfsBaseConditional {
-  protected final char flag = 'z';
+  protected static final char flag = 'z';
   protected char getFlag() { return flag; }
 }

+ 29 - 0
hadoop-tools/hadoop-datajoin/dev-support/findbugs-exclude.xml

@@ -0,0 +1,29 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<FindBugsFilter>
+  <!-- These fields are useful for MapReduce jobs, so leave them as-is. -->
+  <Match>
+    <Class name="org.apache.hadoop.contrib.utils.join.DataJoinMapperBase" />
+    <Field name="inputTag" />
+    <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" />
+  </Match>
+  <Match>
+    <Class name="org.apache.hadoop.contrib.utils.join.DataJoinMapperBase" />
+    <Field name="job" />
+    <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" />
+  </Match>
+</FindBugsFilter>

+ 11 - 0
hadoop-tools/hadoop-datajoin/pom.xml

@@ -108,6 +108,17 @@
 
   <build>
     <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+        <configuration>
+          <findbugsXmlOutput>true</findbugsXmlOutput>
+          <xmlOutput>true</xmlOutput>
+          <excludeFilterFile>${basedir}/dev-support/findbugs-exclude.xml
+          </excludeFilterFile>
+          <effort>Max</effort>
+        </configuration>
+      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-antrun-plugin</artifactId>