Program: 70950
Project: 70950
Buggy source:
/** 
 * @param cwa
 * @return
 * @throws ChartException
 * @throws IllegalArgumentException
 */
static final StackedSeriesLookup create(ChartWithAxes cwa,RunTimeContext rtc) throws ChartException, IllegalArgumentException {
  if (cwa == null) {
    return null;
  }
  final StackedSeriesLookup ssl=new StackedSeriesLookup(rtc);
  final Axis axBase=cwa.getBaseAxes()[0];
  final Axis[] axaOrthogonal=cwa.getOrthogonalAxes(axBase,true);
  EList<?> el;
  List<?> alSeries;
  int iSeriesCount;
  StackGroup sg, sgSingle;
  Series se;
  boolean bStackedSet;
  SeriesDefinition sd;
  int iSharedUnitIndex, iSharedUnitCount, iDataSetCount;
  ArrayList<StackGroup> alSGCopies;
  DataSetIterator dsi=null;
  for (int i=0; i < axaOrthogonal.length; i++) {
    iSharedUnitIndex=0;
    iSharedUnitCount=0;
    sgSingle=null;
    el=axaOrthogonal[i].getSeriesDefinitions();
    alSGCopies=new ArrayList<StackGroup>(4);
    iSharedUnitCount=0;
    for (int j=0; j < el.size(); j++) {
      sd=(SeriesDefinition)el.get(j);
      alSeries=sd.getRunTimeSeries();
      iSeriesCount=alSeries.size();
      if (iSeriesCount > 1) {
        bStackedSet=false;
        sg=null;
        for (int k=0; k < iSeriesCount; k++) {
          se=(Series)alSeries.get(k);
          dsi=new DataSetIterator(se.getDataSet());
          iDataSetCount=dsi.size();
          if (ssl.iCachedUnitCount == 0) {
            ssl.iCachedUnitCount=iDataSetCount;
          }
 else           if (ssl.iCachedUnitCount != iDataSetCount) {
            throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{new Integer(ssl.iCachedUnitCount),new Integer(iDataSetCount)}));
          }
          if (se.canBeStacked()) {
            if (!se.isSetStacked()) {
              throw new ChartException(ChartEnginePlugin.ID,ChartException.UNDEFINED_VALUE,"String_Node_Str",new Object[]{se},Messages.getResourceBundle(rtc.getULocale()));
            }
            if (se.canShareAxisUnit()) {
              if (se.isStacked()) {
                if (k > 0 && !bStackedSet) {
                  throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{sd}));
                }
                if (k == 0) {
                  sg=new StackGroup(iSharedUnitIndex++);
                  alSGCopies.add(sg);
                  iSharedUnitCount++;
                }
                bStackedSet=true;
                ssl.htSeriesToStackGroup.put(se,sg);
                sg.addSeries(se);
              }
 else {
                if (k > 0 && bStackedSet) {
                  throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{sd}));
                }
                sg=new StackGroup(iSharedUnitIndex++);
                alSGCopies.add(sg);
                iSharedUnitCount++;
                ssl.htSeriesToStackGroup.put(se,sg);
                sg.addSeries(se);
              }
            }
 else {
              if (se.isStacked()) {
                if (k > 0 && !bStackedSet) {
                  throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{sd}));
                }
                if (k == 0) {
                  sg=new StackGroup(-1);
                  alSGCopies.add(sg);
                }
                bStackedSet=true;
                ssl.htSeriesToStackGroup.put(se,sg);
                sg.addSeries(se);
              }
 else {
                if (k > 0 && bStackedSet) {
                  throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{sd}));
                }
                sg=new StackGroup(-1);
                alSGCopies.add(sg);
                ssl.htSeriesToStackGroup.put(se,sg);
                sg.addSeries(se);
              }
            }
          }
 else           if (se.canShareAxisUnit()) {
            sg=new StackGroup(iSharedUnitIndex++);
            alSGCopies.add(sg);
            iSharedUnitCount++;
            ssl.htSeriesToStackGroup.put(se,sg);
            sg.addSeries(se);
          }
 else {
            sg=new StackGroup(-1);
            alSGCopies.add(sg);
            ssl.htSeriesToStackGroup.put(se,sg);
            sg.addSeries(se);
          }
        }
      }
 else {
        for (int k=0; k < iSeriesCount; k++) {
          se=(Series)alSeries.get(k);
          dsi=new DataSetIterator(se.getDataSet());
          iDataSetCount=dsi.size();
          if (ssl.iCachedUnitCount == 0) {
            ssl.iCachedUnitCount=iDataSetCount;
          }
 else           if (ssl.iCachedUnitCount != iDataSetCount) {
            throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{new Integer(ssl.iCachedUnitCount),new Integer(iDataSetCount)}));
          }
          if (se.canBeStacked()) {
            if (se.canShareAxisUnit()) {
              if (se.isStacked()) {
                if (sgSingle == null) {
                  sgSingle=new StackGroup(iSharedUnitIndex++);
                  alSGCopies.add(sgSingle);
                  iSharedUnitCount++;
                }
                ssl.htSeriesToStackGroup.put(se,sgSingle);
                sgSingle.addSeries(se);
              }
 else {
                sg=new StackGroup(iSharedUnitIndex++);
                iSharedUnitCount++;
                alSGCopies.add(sg);
                ssl.htSeriesToStackGroup.put(se,sg);
                sg.addSeries(se);
              }
            }
 else {
              sg=new StackGroup(-1);
              alSGCopies.add(sg);
              ssl.htSeriesToStackGroup.put(se,sg);
              sg.addSeries(se);
            }
          }
 else {
            sg=new StackGroup(-1);
            alSGCopies.add(sg);
            ssl.htSeriesToStackGroup.put(se,sg);
            sg.addSeries(se);
          }
        }
      }
    }
    if (iSharedUnitCount < 1)     iSharedUnitCount=1;
    for (int j=0; j < alSGCopies.size(); j++) {
      sg=alSGCopies.get(j);
{
        sg.updateCount(iSharedUnitCount);
      }
    }
    ssl.htAxisToStackGroups.put(axaOrthogonal[i],alSGCopies);
  }
  return ssl;
}

Fixed version (ground truth):
/** 
 * @param cwa
 * @return
 * @throws ChartException
 * @throws IllegalArgumentException
 */
static final StackedSeriesLookup create(ChartWithAxes cwa,RunTimeContext rtc) throws ChartException, IllegalArgumentException {
  if (cwa == null) {
    return null;
  }
  final StackedSeriesLookup ssl=new StackedSeriesLookup(rtc);
  final Axis axBase=cwa.getBaseAxes()[0];
  final Axis[] axaOrthogonal=cwa.getOrthogonalAxes(axBase,true);
  int iSeriesCount;
  StackGroup sg, sgSingle;
  Series se;
  boolean bStackedSet;
  int iSharedUnitIndex, iSharedUnitCount, iDataSetCount;
  DataSetIterator dsi=null;
  for (int i=0; i < axaOrthogonal.length; i++) {
    iSharedUnitIndex=0;
    iSharedUnitCount=0;
    sgSingle=null;
    EList<SeriesDefinition> sdList=axaOrthogonal[i].getSeriesDefinitions();
    List<StackGroup> alSGCopies=new ArrayList<StackGroup>(4);
    iSharedUnitCount=0;
    for (    SeriesDefinition sd : sdList) {
      List<Series> alSeries=sd.getRunTimeSeries();
      iSeriesCount=alSeries.size();
      if (iSeriesCount > 1) {
        bStackedSet=false;
        sg=null;
        for (int k=0; k < iSeriesCount; k++) {
          se=alSeries.get(k);
          dsi=new DataSetIterator(se.getDataSet());
          iDataSetCount=dsi.size();
          if (ssl.iCachedUnitCount == 0) {
            ssl.iCachedUnitCount=iDataSetCount;
          }
 else           if (ssl.iCachedUnitCount != iDataSetCount) {
            throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{new Integer(ssl.iCachedUnitCount),new Integer(iDataSetCount)}));
          }
          if (se.canBeStacked()) {
            if (!se.isSetStacked()) {
              throw new ChartException(ChartEnginePlugin.ID,ChartException.UNDEFINED_VALUE,"String_Node_Str",new Object[]{se},Messages.getResourceBundle(rtc.getULocale()));
            }
            if (se.canShareAxisUnit()) {
              if (se.isStacked()) {
                if (k > 0 && !bStackedSet) {
                  throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{sd}));
                }
                if (k == 0) {
                  sg=new StackGroup(iSharedUnitIndex++);
                  alSGCopies.add(sg);
                  iSharedUnitCount++;
                }
                bStackedSet=true;
                ssl.htSeriesToStackGroup.put(se,sg);
                sg.addSeries(se);
              }
 else {
                if (k > 0 && bStackedSet) {
                  throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{sd}));
                }
                if (canSideBySide(se)) {
                  sg=new StackGroup(iSharedUnitIndex++);
                  alSGCopies.add(sg);
                  iSharedUnitCount++;
                  ssl.htSeriesToStackGroup.put(se,sg);
                  sg.addSeries(se);
                }
              }
            }
 else {
              if (se.isStacked()) {
                if (k > 0 && !bStackedSet) {
                  throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{sd}));
                }
                if (k == 0) {
                  sg=new StackGroup(-1);
                  alSGCopies.add(sg);
                }
                bStackedSet=true;
                ssl.htSeriesToStackGroup.put(se,sg);
                sg.addSeries(se);
              }
 else {
                if (k > 0 && bStackedSet) {
                  throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{sd}));
                }
                sg=new StackGroup(-1);
                alSGCopies.add(sg);
                ssl.htSeriesToStackGroup.put(se,sg);
                sg.addSeries(se);
              }
            }
          }
 else           if (se.canShareAxisUnit()) {
            sg=new StackGroup(iSharedUnitIndex++);
            alSGCopies.add(sg);
            iSharedUnitCount++;
            ssl.htSeriesToStackGroup.put(se,sg);
            sg.addSeries(se);
          }
 else {
            sg=new StackGroup(-1);
            alSGCopies.add(sg);
            ssl.htSeriesToStackGroup.put(se,sg);
            sg.addSeries(se);
          }
        }
      }
 else {
        for (int k=0; k < iSeriesCount; k++) {
          se=alSeries.get(k);
          dsi=new DataSetIterator(se.getDataSet());
          iDataSetCount=dsi.size();
          if (ssl.iCachedUnitCount == 0) {
            ssl.iCachedUnitCount=iDataSetCount;
          }
 else           if (ssl.iCachedUnitCount != iDataSetCount) {
            throw new IllegalArgumentException(MessageFormat.format(Messages.getResourceBundle(rtc.getULocale()).getString("String_Node_Str"),new Object[]{new Integer(ssl.iCachedUnitCount),new Integer(iDataSetCount)}));
          }
          if (se.canBeStacked()) {
            if (se.canShareAxisUnit()) {
              if (se.isStacked()) {
                if (sgSingle == null) {
                  sgSingle=new StackGroup(iSharedUnitIndex++);
                  alSGCopies.add(sgSingle);
                  iSharedUnitCount++;
                }
                ssl.htSeriesToStackGroup.put(se,sgSingle);
                sgSingle.addSeries(se);
              }
 else {
                if (canSideBySide(se)) {
                  sg=new StackGroup(iSharedUnitIndex++);
                  iSharedUnitCount++;
                  alSGCopies.add(sg);
                  ssl.htSeriesToStackGroup.put(se,sg);
                  sg.addSeries(se);
                }
              }
            }
 else {
              sg=new StackGroup(-1);
              alSGCopies.add(sg);
              ssl.htSeriesToStackGroup.put(se,sg);
              sg.addSeries(se);
            }
          }
 else {
            sg=new StackGroup(-1);
            alSGCopies.add(sg);
            ssl.htSeriesToStackGroup.put(se,sg);
            sg.addSeries(se);
          }
        }
      }
    }
    if (iSharedUnitCount < 1)     iSharedUnitCount=1;
    for (int j=0; j < alSGCopies.size(); j++) {
      sg=alSGCopies.get(j);
      sg.updateCount(iSharedUnitCount);
    }
    ssl.htAxisToStackGroups.put(axaOrthogonal[i],alSGCopies);
  }
  return ssl;
}