PDA

View Full Version : [FNR] Bug with SummaryType.MAX



aruille
12 Apr 2011, 1:23 AM
Hi,

SummaryType.MAX is not valid with only negatives values.

initialization of the variable max is incorrect with only negatives values :

Double max = (Double) data.get(field + "max");
if (max == null) {
max = new Double(0);
}

this is correct :

public static final SummaryType<Double> MAX = new SummaryType<Double>() {
@Override
public Double render(Object v, ModelData m, String field, Map<String, Object> data) {
Object obj = m.get(field);
Double current = obj != null ? ((Number) obj).doubleValue() : 0d;

Double max = (Double) data.get(field + "max");
if ( max == null ) {
max = current;
}

max = Math.max(max, current);
data.put(field + "max", max);
return max;
}
};

Antoine

sven
13 Sep 2011, 5:44 AM
Fixed in SVN.