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

This commit is contained in:
Masatake Iwasaki 2016-04-29 20:25:52 +09:00
parent 0f25a1bb52
commit ef0870ad03
6 changed files with 50 additions and 5 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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>

View File

@ -108,6 +108,17 @@
<build> <build>
<plugins> <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> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId> <artifactId>maven-antrun-plugin</artifactId>