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
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
INCOMPATIBLE CHANGES

View File

@ -151,11 +151,10 @@ Map<Parameter, List<TaskResult>> parse(String inputpath, String outputdir
static <T extends Combinable<T>> Map<Parameter, T> combine(Map<Parameter, List<T>> m) {
final Map<Parameter, T> combined = new TreeMap<Parameter, T>();
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));
Util.out.format("%-6s => ", p);
if (results == null)
Util.out.println("null");
else if (results.size() != 1)
if (results.size() != 1)
Util.out.println(results.toString().replace(", ", ",\n "));
else {
final T r = results.get(0);

View File

@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.NoSuchElementException;
import org.apache.hadoop.examples.pi.Container;
import org.apache.hadoop.examples.pi.Util;
@ -255,7 +256,13 @@ public Iterator<Summation> iterator() {
public boolean hasNext() {return i < parts.length;}
/** {@inheritDoc} */
@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 */
@Override
public void remove() {throw new UnsupportedOperationException();}