From ef0870ad038a1b72ea14ce550e34139b81eb901b Mon Sep 17 00:00:00 2001 From: Masatake Iwasaki Date: Fri, 29 Apr 2016 20:25:52 +0900 Subject: [PATCH] HADOOP-12378. Fix findbugs warnings in hadoop-tools module. Contributed by Akira AJISAKA. --- .../java/org/apache/hadoop/ant/DfsTask.java | 9 ++++-- .../hadoop/ant/condition/DfsExists.java | 2 +- .../apache/hadoop/ant/condition/DfsIsDir.java | 2 +- .../hadoop/ant/condition/DfsZeroLen.java | 2 +- .../dev-support/findbugs-exclude.xml | 29 +++++++++++++++++++ hadoop-tools/hadoop-datajoin/pom.xml | 11 +++++++ 6 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 hadoop-tools/hadoop-datajoin/dev-support/findbugs-exclude.xml diff --git a/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/DfsTask.java b/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/DfsTask.java index 8dc7f3766e..36119f5aac 100644 --- a/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/DfsTask.java +++ b/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/DfsTask.java @@ -21,6 +21,7 @@ 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 void setFailonerror(boolean failonerror) { 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) { + } } /** diff --git a/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsExists.java b/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsExists.java index 8fbe872a83..95e3868795 100644 --- a/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsExists.java +++ b/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; } } diff --git a/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsIsDir.java b/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsIsDir.java index e146d06dcf..b889615896 100644 --- a/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsIsDir.java +++ b/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; } } diff --git a/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsZeroLen.java b/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsZeroLen.java index caac37847b..70b4fbf223 100644 --- a/hadoop-tools/hadoop-ant/src/main/java/org/apache/hadoop/ant/condition/DfsZeroLen.java +++ b/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; } } diff --git a/hadoop-tools/hadoop-datajoin/dev-support/findbugs-exclude.xml b/hadoop-tools/hadoop-datajoin/dev-support/findbugs-exclude.xml new file mode 100644 index 0000000000..3544581dba --- /dev/null +++ b/hadoop-tools/hadoop-datajoin/dev-support/findbugs-exclude.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + diff --git a/hadoop-tools/hadoop-datajoin/pom.xml b/hadoop-tools/hadoop-datajoin/pom.xml index 40445cb9ab..03669b20d9 100644 --- a/hadoop-tools/hadoop-datajoin/pom.xml +++ b/hadoop-tools/hadoop-datajoin/pom.xml @@ -108,6 +108,17 @@ + + org.codehaus.mojo + findbugs-maven-plugin + + true + true + ${basedir}/dev-support/findbugs-exclude.xml + + Max + + org.apache.maven.plugins maven-antrun-plugin