HADOOP-11372. Fix new findbugs warnings in mapreduce-examples. Contributed by Li Lu.

This commit is contained in:
Haohui Mai 2014-12-09 10:48:35 -08:00
parent deaa172e7a
commit 49aacee2cb
3 changed files with 13 additions and 4 deletions

View File

@ -176,6 +176,9 @@ Release 2.7.0 - UNRELEASED
HADOOP-11368. Fix SSLFactory truststore reloader thread leak in HADOOP-11368. Fix SSLFactory truststore reloader thread leak in
KMSClientProvider. (Arun Suresh via wang) KMSClientProvider. (Arun Suresh via wang)
HADOOP-11372. Fix new findbugs warnings in mapreduce-examples.
(Li Lu via wheat9)
Release 2.6.0 - 2014-11-18 Release 2.6.0 - 2014-11-18
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -151,11 +151,10 @@ public final class Parser {
static <T extends Combinable<T>> Map<Parameter, T> combine(Map<Parameter, List<T>> m) { static <T extends Combinable<T>> Map<Parameter, T> combine(Map<Parameter, List<T>> m) {
final Map<Parameter, T> combined = new TreeMap<Parameter, T>(); final Map<Parameter, T> combined = new TreeMap<Parameter, T>();
for(Parameter p : Parameter.values()) { for(Parameter p : Parameter.values()) {
//note: results would never be null due to the design of Util.combine
final List<T> results = Util.combine(m.get(p)); final List<T> results = Util.combine(m.get(p));
Util.out.format("%-6s => ", p); Util.out.format("%-6s => ", p);
if (results == null) if (results.size() != 1)
Util.out.println("null");
else if (results.size() != 1)
Util.out.println(results.toString().replace(", ", ",\n ")); Util.out.println(results.toString().replace(", ", ",\n "));
else { else {
final T r = results.get(0); final T r = results.get(0);

View File

@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.NoSuchElementException;
import org.apache.hadoop.examples.pi.Container; import org.apache.hadoop.examples.pi.Container;
import org.apache.hadoop.examples.pi.Util; import org.apache.hadoop.examples.pi.Util;
@ -255,7 +256,13 @@ public final class Bellard {
public boolean hasNext() {return i < parts.length;} public boolean hasNext() {return i < parts.length;}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public Summation next() {return parts[i++];} public Summation next() throws NoSuchElementException {
if (hasNext()) {
return parts[i++];
} else {
throw new NoSuchElementException("Sum's iterator does not have next!");
}
}
/** Unsupported */ /** Unsupported */
@Override @Override
public void remove() {throw new UnsupportedOperationException();} public void remove() {throw new UnsupportedOperationException();}