Program: 65338
Project: 65338
Buggy source:
@Override protected final Object getMinMax(Axis ax,int iType) throws ChartException, IllegalArgumentException {
  if (ax.getType().getValue() == AxisType.LINEAR && ax.isAligned() && azHelper != null) {
    double[] minmax=azHelper.getCachedMinMax(ax);
    if (minmax != null) {
      return minmax;
    }
  }
  ChartWithAxes cwa=getModel();
  final Series[] sea=ax.getRuntimeSeries();
  final int iSeriesCount=sea.length;
  Series se;
  DataSet ds=null;
  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();
    if (ds instanceof NullDataSet && rtc.getSharedScale() != null) {
      oMin=rtc.getSharedScale().getScaleContext().getMin();
      oMax=rtc.getSharedScale().getScaleContext().getMax();
    }
 else {
      oV1=iDSP.getMinimum(ds);
      oV2=iDSP.getMaximum(ds);
      if ((iType & NUMERICAL) == NUMERICAL) {
        try {
          if (oV1 != null) {
            if (oMin == null) {
              oMin=oV1;
            }
 else {
              if (NumberUtil.isBigNumber(oV1)) {
                oMin=((BigNumber)oMin).min((BigNumber)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 {
              if (NumberUtil.isBigNumber(oV2)) {
                oMax=((BigNumber)oMax).max((BigNumber)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()));
        }
      }
    }
  }
  boolean isbignumber=false;
  BigDecimal bigDivisor=null;
  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;
    List<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) {
          for (int j=0; j < iSeriesPerGroup; j++) {
            se=alSeriesPerGroup.get(j);
            ds=se.getDataSet();
            if (ds instanceof NullDataSet) {
              continue;
            }
 else {
              break;
            }
          }
          if (ds == null) {
            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=((Number)oValue).doubleValue();
              au.computeTotal(dValue);
              if (NumberUtil.isBigNumber(oValue) && !isbignumber) {
                isbignumber=true;
                bigDivisor=((BigNumber)oValue).getDivisor();
              }
            }
            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 == null || Double.compare(dAxisMin,((Number)oMin).doubleValue()) < 0)) {
      if (isbignumber && !ax.isPercent()) {
        oMin=new BigNumber(BigDecimal.valueOf(dAxisMin).multiply(bigDivisor,NumberUtil.DEFAULT_MATHCONTEXT),bigDivisor);
      }
 else {
        oMin=new Double(dAxisMin);
      }
    }
    if (dAxisMax != -Double.MAX_VALUE && (oMax == null || Double.compare(dAxisMax,((Number)oMax).doubleValue()) > 0)) {
      if (isbignumber && !ax.isPercent()) {
        oMax=new BigNumber(BigDecimal.valueOf(dAxisMax).multiply(bigDivisor,NumberUtil.DEFAULT_MATHCONTEXT),bigDivisor);
      }
 else {
        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 {
      return adjustMinMax(oMin,oMax);
    }
 catch (    ClassCastException ex) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
    }
  }
  return null;
}

Fixed version (ground truth):
@Override protected final Object getMinMax(Axis ax,int iType) throws ChartException, IllegalArgumentException {
  if (ax.getType().getValue() == AxisType.LINEAR && ax.isAligned() && azHelper != null) {
    double[] minmax=azHelper.getCachedMinMax(ax);
    if (minmax != null) {
      return minmax;
    }
  }
  ChartWithAxes cwa=getModel();
  final Series[] sea=ax.getRuntimeSeries();
  final int iSeriesCount=sea.length;
  Series se;
  DataSet ds=null;
  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();
    if (ds instanceof NullDataSet && rtc.getSharedScale() != null) {
      oMin=rtc.getSharedScale().getScaleContext().getMin();
      oMax=rtc.getSharedScale().getScaleContext().getMax();
    }
 else {
      oV1=iDSP.getMinimum(ds);
      oV2=iDSP.getMaximum(ds);
      if ((iType & NUMERICAL) == NUMERICAL) {
        try {
          if (oV1 != null) {
            if (oMin == null) {
              oMin=oV1;
            }
 else {
              if (NumberUtil.isBigNumber(oV1)) {
                oMin=((BigNumber)oMin).min((BigNumber)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 {
              if (NumberUtil.isBigNumber(oV2)) {
                oMax=((BigNumber)oMax).max((BigNumber)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()));
        }
      }
    }
  }
  boolean isbignumber=false;
  BigDecimal bigDivisor=null;
  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;
    List<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) {
          for (int j=0; j < iSeriesPerGroup; j++) {
            se=alSeriesPerGroup.get(j);
            ds=se.getDataSet();
            if (ds instanceof NullDataSet) {
              ds=null;
              continue;
            }
 else {
              break;
            }
          }
          if (ds == null) {
            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=((Number)oValue).doubleValue();
              au.computeTotal(dValue);
              if (NumberUtil.isBigNumber(oValue) && !isbignumber) {
                isbignumber=true;
                bigDivisor=((BigNumber)oValue).getDivisor();
              }
            }
            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 == null || Double.compare(dAxisMin,((Number)oMin).doubleValue()) < 0)) {
      if (isbignumber && !ax.isPercent()) {
        oMin=new BigNumber(BigDecimal.valueOf(dAxisMin).multiply(bigDivisor,NumberUtil.DEFAULT_MATHCONTEXT),bigDivisor);
      }
 else {
        oMin=new Double(dAxisMin);
      }
    }
    if (dAxisMax != -Double.MAX_VALUE && (oMax == null || Double.compare(dAxisMax,((Number)oMax).doubleValue()) > 0)) {
      if (isbignumber && !ax.isPercent()) {
        oMax=new BigNumber(BigDecimal.valueOf(dAxisMax).multiply(bigDivisor,NumberUtil.DEFAULT_MATHCONTEXT),bigDivisor);
      }
 else {
        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 {
      return adjustMinMax(oMin,oMax);
    }
 catch (    ClassCastException ex) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.DATA_SET,"String_Node_Str",Messages.getResourceBundle(rtc.getULocale()));
    }
  }
  return null;
}