Program: 71525
Project: 71525
Buggy source:
/** 
 * This method pulls out the 'min' and 'max' value for all datasets associated with a single axis using the custom data source processor implementation
 * @param ax The orthogonal axis for which the min/max values are being computed
 * @param iType The renderer's axis data type
 * @return
 */
private final Object getMinMax(Axis ax,int iType) throws ChartException, IllegalArgumentException {
  final Series[] sea=ax.getRuntimeSeries();
  final int iSeriesCount=sea.length;
  Series se;
  DataSet ds;
  Object oV1, oV2, oMin=null, oMax=null;
  PluginSettings ps=PluginSettings.instance();
  IDataSetProcessor iDSP=null;
  boolean bAnyStacked=false;
  for (int i=0; i < iSeriesCount; i++) {
    if (sea[i].isStacked()) {
      if (sea[i].canBeStacked()) {
        bAnyStacked=true;
        continue;
      }
 else {
        throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{sea[i]}));
      }
    }
    iDSP=ps.getDataSetProcessor(sea[i].getClass());
    ds=sea[i].getDataSet();
    oV1=iDSP.getMinimum(ds);
    oV2=iDSP.getMaximum(ds);
    if ((iType & NUMERICAL) == NUMERICAL) {
      try {
        if (oV1 != null) {
          if (oMin == null) {
            oMin=oV1;
          }
 else {
            final double dV1=asDouble(oV1).doubleValue();
            if (Math.min(asDouble(oMin).doubleValue(),dV1) == dV1) {
              oMin=oV1;
            }
          }
        }
        if (oV2 != null) {
          if (oMax == null) {
            oMax=oV2;
          }
 else {
            final double dV2=asDouble(oV2).doubleValue();
            if (Math.max(asDouble(oMax).doubleValue(),dV2) == dV2) {
              oMax=oV2;
            }
          }
        }
      }
 catch (      ClassCastException ex) {
        throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
      }
    }
 else     if ((iType & DATE_TIME) == DATE_TIME) {
      try {
        if (oV1 != null) {
          if (oMin == null) {
            oMin=oV1;
          }
 else {
            final CDateTime cdtV1=asDateTime(oV1);
            final CDateTime cdtMin=asDateTime(oMin);
            if (cdtV1.before(cdtMin)) {
              oMin=cdtV1;
            }
          }
        }
        if (oV2 != null) {
          if (oMax == null) {
            oMax=oV2;
          }
 else {
            final CDateTime cdtV2=asDateTime(oV2);
            final CDateTime cdtMax=asDateTime(oMax);
            if (cdtV2.after(cdtMax)) {
              oMax=cdtV2;
            }
          }
        }
      }
 catch (      ClassCastException ex) {
        throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
      }
    }
  }
  if (bAnyStacked || ax.isPercent()) {
    if (ax.getType().getValue() == AxisType.DATE_TIME) {
      throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{ax}));
    }
    Object oValue;
    int iSeriesPerGroup;
    double dPercentMax=0, dPercentMin=0;
    double dAxisMin=Double.MAX_VALUE, dAxisMax=-Double.MAX_VALUE;
    ArrayList<StackGroup> alSeriesGroupsPerAxis=ssl.getStackGroups(ax);
    ArrayList<Series> alSeriesPerGroup;
    StackGroup sg;
    DataSetIterator[] dsi=new DataSetIterator[ssl.getSeriesCount(ax)];
    if (alSeriesGroupsPerAxis == null) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",new Object[]{ax},Messages.getResourceBundle(rtc.getULocale()));
    }
    logger.log(ILogger.INFORMATION,Messages.getString("String_Node_Str",new Object[]{ax},rtc.getULocale()));
    int iSeriesIndex, iDataSetCount=ssl.getUnitCount();
    for (int k=0; k < iDataSetCount; k++) {
      iSeriesIndex=0;
      for (int i=0; i < alSeriesGroupsPerAxis.size(); i++) {
        sg=alSeriesGroupsPerAxis.get(i);
        alSeriesPerGroup=sg.getSeries();
        iSeriesPerGroup=alSeriesPerGroup.size();
        if (iSeriesPerGroup > 0) {
          se=alSeriesPerGroup.get(0);
          ds=se.getDataSet();
          if (ds instanceof NullDataSet) {
            continue;
          }
          if (dsi[iSeriesIndex] == null) {
            dsi[iSeriesIndex]=new DataSetIterator(ds);
            dsi[iSeriesIndex].reverse(cwa.isReverseCategory());
            if ((dsi[iSeriesIndex].getDataType() & IConstants.NUMERICAL) != IConstants.NUMERICAL) {
              throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
            }
          }
          iDataSetCount=dsi[iSeriesIndex].size();
          final AxisSubUnit au=ssl.getSubUnit(sg,k);
          for (int j=0; j < iSeriesPerGroup; j++) {
            se=alSeriesPerGroup.get(j);
            if (j > 0) {
              if (dsi[iSeriesIndex] == null) {
                ds=se.getDataSet();
                dsi[iSeriesIndex]=new DataSetIterator(ds);
                dsi[iSeriesIndex].reverse(cwa.isReverseCategory());
                if ((dsi[iSeriesIndex].getDataType() & IConstants.NUMERICAL) != IConstants.NUMERICAL) {
                  throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
                }
              }
            }
            oValue=dsi[iSeriesIndex].next();
            if (oValue != null) {
              double dValue=((Double)oValue).doubleValue();
              au.computeTotal(dValue);
            }
            iSeriesIndex++;
          }
          if (ax.isPercent()) {
            double dAbsTotal=au.getPositiveTotal() - au.getNegativeTotal();
            if (dAbsTotal != 0d) {
              dPercentMax=Math.max((au.getTotalMax() / dAbsTotal) * 100d,dPercentMax);
              dPercentMin=Math.min((au.getTotalMin() / dAbsTotal) * 100d,dPercentMin);
            }
          }
 else {
            dAxisMax=Math.max(au.getTotalMax(),dAxisMax);
            dAxisMin=Math.min(au.getTotalMin(),dAxisMin);
          }
        }
      }
    }
    if (ax.isPercent()) {
      if (dPercentMax > 100)       dPercentMax=100;
      if (dPercentMin < -100)       dPercentMin=-100;
      if (dPercentMax == 0 && dPercentMin == 0) {
        dPercentMax=100;
      }
      dAxisMin=dPercentMin;
      dAxisMax=dPercentMax;
    }
    if ((iType & LOGARITHMIC) == LOGARITHMIC) {
      dAxisMin=1;
    }
    if (dAxisMin != Double.MAX_VALUE) {
      oMin=new Double(dAxisMin);
    }
    if (dAxisMax != -Double.MAX_VALUE) {
      oMax=new Double(dAxisMax);
    }
  }
  if (oMin == null && oMax == null) {
    if (iType == DATE_TIME) {
      int year=Calendar.getInstance().get(Calendar.YEAR);
      oMin=new CDateTime(year,1,1);
      oMax=new CDateTime(year,12,31);
    }
 else     if ((iType & NUMERICAL) == NUMERICAL) {
      if ((iType & PERCENT) == PERCENT) {
        oMin=new Double(0);
        oMax=new Double(100);
      }
 else       if ((iType & LOGARITHMIC) == LOGARITHMIC) {
        oMin=new Double(1);
        oMax=new Double(1000);
      }
 else {
        oMin=new Double(-1);
        oMax=new Double(1);
      }
    }
  }
  if (iType == DATE_TIME) {
    try {
      CDateTime dtMin=asDateTime(oMin);
      CDateTime dtMax=asDateTime(oMax);
      return new Calendar[]{dtMin,dtMax};
    }
 catch (    ClassCastException ex) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
    }
  }
 else   if ((iType & NUMERICAL) == NUMERICAL) {
    try {
      double dMin=asDouble(oMin).doubleValue();
      double dMax=asDouble(oMax).doubleValue();
      if (dMin == dMax) {
        if (dMin > 0) {
          dMin=0;
        }
        if (dMax < 0) {
          dMax=0;
        }
      }
      return new double[]{dMin,dMax};
    }
 catch (    ClassCastException ex) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * This method pulls out the 'min' and 'max' value for all datasets associated with a single axis using the custom data source processor implementation
 * @param ax The orthogonal axis for which the min/max values are being computed
 * @param iType The renderer's axis data type
 * @return
 */
private final Object getMinMax(Axis ax,int iType) throws ChartException, IllegalArgumentException {
  final Series[] sea=ax.getRuntimeSeries();
  final int iSeriesCount=sea.length;
  Series se;
  DataSet ds;
  Object oV1, oV2, oMin=null, oMax=null;
  PluginSettings ps=PluginSettings.instance();
  IDataSetProcessor iDSP=null;
  boolean bAnyStacked=false;
  for (int i=0; i < iSeriesCount; i++) {
    if (sea[i].isStacked()) {
      if (sea[i].canBeStacked()) {
        bAnyStacked=true;
        continue;
      }
 else {
        throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{sea[i]}));
      }
    }
    iDSP=ps.getDataSetProcessor(sea[i].getClass());
    ds=sea[i].getDataSet();
    oV1=iDSP.getMinimum(ds);
    oV2=iDSP.getMaximum(ds);
    if ((iType & NUMERICAL) == NUMERICAL) {
      try {
        if (oV1 != null) {
          if (oMin == null) {
            oMin=oV1;
          }
 else {
            final double dV1=asDouble(oV1).doubleValue();
            if (Math.min(asDouble(oMin).doubleValue(),dV1) == dV1) {
              oMin=oV1;
            }
          }
        }
        if (oV2 != null) {
          if (oMax == null) {
            oMax=oV2;
          }
 else {
            final double dV2=asDouble(oV2).doubleValue();
            if (Math.max(asDouble(oMax).doubleValue(),dV2) == dV2) {
              oMax=oV2;
            }
          }
        }
      }
 catch (      ClassCastException ex) {
        throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
      }
    }
 else     if ((iType & DATE_TIME) == DATE_TIME) {
      try {
        if (oV1 != null) {
          if (oMin == null) {
            oMin=oV1;
          }
 else {
            final CDateTime cdtV1=asDateTime(oV1);
            final CDateTime cdtMin=asDateTime(oMin);
            if (cdtV1.before(cdtMin)) {
              oMin=cdtV1;
            }
          }
        }
        if (oV2 != null) {
          if (oMax == null) {
            oMax=oV2;
          }
 else {
            final CDateTime cdtV2=asDateTime(oV2);
            final CDateTime cdtMax=asDateTime(oMax);
            if (cdtV2.after(cdtMax)) {
              oMax=cdtV2;
            }
          }
        }
      }
 catch (      ClassCastException ex) {
        throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
      }
    }
  }
  if (bAnyStacked || ax.isPercent()) {
    if (ax.getType().getValue() == AxisType.DATE_TIME) {
      throw new IllegalArgumentException(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"));
    }
    Object oValue;
    int iSeriesPerGroup;
    double dPercentMax=0, dPercentMin=0;
    double dAxisMin=Double.MAX_VALUE, dAxisMax=-Double.MAX_VALUE;
    ArrayList<StackGroup> alSeriesGroupsPerAxis=ssl.getStackGroups(ax);
    ArrayList<Series> alSeriesPerGroup;
    StackGroup sg;
    DataSetIterator[] dsi=new DataSetIterator[ssl.getSeriesCount(ax)];
    if (alSeriesGroupsPerAxis == null) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",new Object[]{ax},Messages.getResourceBundle(rtc.getULocale()));
    }
    logger.log(ILogger.INFORMATION,Messages.getString("String_Node_Str",new Object[]{ax},rtc.getULocale()));
    int iSeriesIndex, iDataSetCount=ssl.getUnitCount();
    for (int k=0; k < iDataSetCount; k++) {
      iSeriesIndex=0;
      for (int i=0; i < alSeriesGroupsPerAxis.size(); i++) {
        sg=alSeriesGroupsPerAxis.get(i);
        alSeriesPerGroup=sg.getSeries();
        iSeriesPerGroup=alSeriesPerGroup.size();
        if (iSeriesPerGroup > 0) {
          se=alSeriesPerGroup.get(0);
          ds=se.getDataSet();
          if (ds instanceof NullDataSet) {
            continue;
          }
          if (dsi[iSeriesIndex] == null) {
            dsi[iSeriesIndex]=new DataSetIterator(ds);
            dsi[iSeriesIndex].reverse(cwa.isReverseCategory());
            if ((dsi[iSeriesIndex].getDataType() & IConstants.NUMERICAL) != IConstants.NUMERICAL) {
              throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
            }
          }
          iDataSetCount=dsi[iSeriesIndex].size();
          final AxisSubUnit au=ssl.getSubUnit(sg,k);
          for (int j=0; j < iSeriesPerGroup; j++) {
            se=alSeriesPerGroup.get(j);
            if (j > 0) {
              if (dsi[iSeriesIndex] == null) {
                ds=se.getDataSet();
                dsi[iSeriesIndex]=new DataSetIterator(ds);
                dsi[iSeriesIndex].reverse(cwa.isReverseCategory());
                if ((dsi[iSeriesIndex].getDataType() & IConstants.NUMERICAL) != IConstants.NUMERICAL) {
                  throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
                }
              }
            }
            oValue=dsi[iSeriesIndex].next();
            if (oValue != null) {
              double dValue=((Double)oValue).doubleValue();
              au.computeTotal(dValue);
            }
            iSeriesIndex++;
          }
          if (ax.isPercent()) {
            double dAbsTotal=au.getPositiveTotal() - au.getNegativeTotal();
            if (dAbsTotal != 0d) {
              dPercentMax=Math.max((au.getTotalMax() / dAbsTotal) * 100d,dPercentMax);
              dPercentMin=Math.min((au.getTotalMin() / dAbsTotal) * 100d,dPercentMin);
            }
          }
 else {
            dAxisMax=Math.max(au.getTotalMax(),dAxisMax);
            dAxisMin=Math.min(au.getTotalMin(),dAxisMin);
          }
        }
      }
    }
    if (ax.isPercent()) {
      if (dPercentMax > 100)       dPercentMax=100;
      if (dPercentMin < -100)       dPercentMin=-100;
      if (dPercentMax == 0 && dPercentMin == 0) {
        dPercentMax=100;
      }
      dAxisMin=dPercentMin;
      dAxisMax=dPercentMax;
    }
    if ((iType & LOGARITHMIC) == LOGARITHMIC) {
      dAxisMin=1;
    }
    if (dAxisMin != Double.MAX_VALUE) {
      oMin=new Double(dAxisMin);
    }
    if (dAxisMax != -Double.MAX_VALUE) {
      oMax=new Double(dAxisMax);
    }
  }
  if (oMin == null && oMax == null) {
    if (iType == DATE_TIME) {
      int year=Calendar.getInstance().get(Calendar.YEAR);
      oMin=new CDateTime(year,1,1);
      oMax=new CDateTime(year,12,31);
    }
 else     if ((iType & NUMERICAL) == NUMERICAL) {
      if ((iType & PERCENT) == PERCENT) {
        oMin=new Double(0);
        oMax=new Double(100);
      }
 else       if ((iType & LOGARITHMIC) == LOGARITHMIC) {
        oMin=new Double(1);
        oMax=new Double(1000);
      }
 else {
        oMin=new Double(-1);
        oMax=new Double(1);
      }
    }
  }
  if (iType == DATE_TIME) {
    try {
      CDateTime dtMin=asDateTime(oMin);
      CDateTime dtMax=asDateTime(oMax);
      return new Calendar[]{dtMin,dtMax};
    }
 catch (    ClassCastException ex) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
    }
  }
 else   if ((iType & NUMERICAL) == NUMERICAL) {
    try {
      double dMin=asDouble(oMin).doubleValue();
      double dMax=asDouble(oMax).doubleValue();
      if (dMin == dMax) {
        if (dMin > 0) {
          dMin=0;
        }
        if (dMax < 0) {
          dMax=0;
        }
      }
      return new double[]{dMin,dMax};
    }
 catch (    ClassCastException ex) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
    }
  }
  return null;
}