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 74d4bfded9
commit be86237c09
3 changed files with 13 additions and 4 deletions

View File

@ -542,6 +542,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 @@ public final class Parser {
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.Iterator;
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 final class Bellard {
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();}