Program: 68115
Project: 68115
Buggy source:
/** 
 * @param cwoa
 * @param pie
 * @param dpha
 * @param da
 * @param pa
 */
PieRenderer(ChartWithoutAxes cwoa,Pie pie,DataPointHints[] dpha,double[] da,Palette pa) throws ChartException {
  this.pa=pa;
  this.pie=pie;
  this.cComp=pie.getRunTimeContext().getState(StateKey.CHART_COMPUTATION_KEY);
  ps=(PieSeries)pie.getSeries();
  sExplosionExpression=ps.getExplosionExpression();
  dExplosion=ps.getExplosion() * pie.getDeviceScale();
  dThickness=((cwoa.getDimension() == ChartDimension.TWO_DIMENSIONAL_LITERAL) ? 0 : cwoa.getSeriesThickness()) * pie.getDeviceScale();
  ratio=ps.isSetRatio() ? ps.getRatio() : 1;
  rotation=ps.isSetRotation() ? ps.getRotation() : 0;
  liaLL=ps.getLeaderLineAttributes();
  if (ps.getLeaderLineAttributes().isVisible()) {
    dLeaderLength=ps.getLeaderLineLength() * pie.getDeviceScale();
  }
 else {
    dLeaderLength=0;
  }
  liaEdges=goFactory.createLineAttributes(goFactory.BLACK(),LineStyle.SOLID_LITERAL,1);
  bPaletteByCategory=(cwoa.getLegend().getItemType() == LegendItemType.CATEGORIES_LITERAL);
  lpDataPoint=ps.getLabelPosition();
  lpSeriesTitle=ps.getTitlePosition();
  laSeriesTitle=goFactory.copyOf(ps.getTitle());
  laSeriesTitle.getCaption().setValue(pie.getRunTimeContext().externalizedMessage(String.valueOf(ps.getSeriesIdentifier())));
  laSeriesTitle.getCaption().getFont().setAlignment(pie.switchTextAlignment(laSeriesTitle.getCaption().getFont().getAlignment()));
  final AbstractScriptHandler sh=pie.getRunTimeContext().getScriptHandler();
  ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_SERIES_TITLE,ps,laSeriesTitle,pie.getRunTimeContext().getScriptContext());
  pie.getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_SERIES_TITLE,laSeriesTitle);
  lls=ps.getLeaderLineStyle();
  bMinSliceDefined=cwoa.isSetMinSlice();
  dMinSlice=cwoa.getMinSlice();
  bPercentageMinSlice=cwoa.isMinSlicePercent();
  double dTotal=0;
  orginalSliceCount=da.length;
  for (int i=0; i < da.length; i++) {
    if (da[i] < 0) {
      dTotal-=da[i];
    }
 else     if (!Double.isNaN(da[i])) {
      dTotal+=da[i];
    }
  }
  if (bMinSliceDefined) {
    if (bPercentageMinSlice) {
      dAbsoluteMinSlice=dMinSlice * dTotal / 100d;
    }
 else {
      dAbsoluteMinSlice=dMinSlice;
    }
    double residualPos=0;
    double residualNeg=0;
    DataPointHints dphPos=null;
    DataPointHints dphNeg=null;
    for (int i=0; i < da.length; i++) {
      if (Double.isNaN(da[i])) {
        continue;
      }
      if (Math.abs(da[i]) >= Math.abs(dAbsoluteMinSlice)) {
        pieSliceList.add(new PieSlice(da[i],dpha[i],i));
      }
 else {
        if (da[i] >= 0) {
          residualPos+=da[i];
          if (dphPos == null) {
            dphPos=dpha[i].getVirtualCopy();
          }
 else {
            dphPos.accumulate(dpha[i].getBaseValue(),dpha[i].getOrthogonalValue(),dpha[i].getSeriesValue(),dpha[i].getPercentileOrthogonalValue());
          }
        }
 else {
          residualNeg+=da[i];
          if (dphNeg == null) {
            dphNeg=dpha[i].getVirtualCopy();
          }
 else {
            dphNeg.accumulate(dpha[i].getBaseValue(),dpha[i].getOrthogonalValue(),dpha[i].getSeriesValue(),dpha[i].getPercentileOrthogonalValue());
          }
        }
      }
    }
    String extSliceLabel=pie.getRunTimeContext().externalizedMessage(cwoa.getMinSliceLabel());
    if (dphPos != null) {
      dphPos.setBaseValue(extSliceLabel);
      dphPos.setIndex(orginalSliceCount);
      pieSliceList.add(new PieSlice(residualPos,dphPos,orginalSliceCount));
      bMinSliceApplied=true;
    }
    if (dphNeg != null) {
      dphNeg.setBaseValue(extSliceLabel);
      dphNeg.setIndex(orginalSliceCount);
      pieSliceList.add(new PieSlice(residualNeg,dphNeg,orginalSliceCount));
      bMinSliceApplied=true;
    }
  }
 else {
    for (int i=0; i < da.length; i++) {
      if (Double.isNaN(da[i])) {
        continue;
      }
      pieSliceList.add(new PieSlice(da[i],dpha[i],i));
    }
  }
  double startAngle=rotation;
  double originalStartAngle=rotation;
  if (dTotal == 0) {
    dTotal=1;
  }
  PieSlice slice=null;
  double totalAngle=0d;
  for (Iterator iter=pieSliceList.iterator(); iter.hasNext(); ) {
    slice=(PieSlice)iter.next();
    double length=(Math.abs(slice.getPrimitiveValue()) / dTotal) * 360d;
    double percentage=(slice.getPrimitiveValue() / dTotal) * 100d;
    slice.setStartAngle(startAngle);
    slice.setOriginalStartAngle(originalStartAngle);
    slice.setSliceLength(length);
    slice.setPercentage(percentage);
    startAngle+=length + MIN_DOUBLE;
    originalStartAngle+=length;
    startAngle=wrapAngle(startAngle);
    originalStartAngle=wrapAngle(originalStartAngle);
    totalAngle+=length;
  }
  if (totalAngle > 0 && 360 - totalAngle > 0.001) {
    slice.setSliceLength(360 - slice.getStartAngle());
  }
  initExploded();
}

Fixed version (ground truth):
/** 
 * @param cwoa
 * @param pie
 * @param dpha
 * @param da
 * @param pa
 */
PieRenderer(ChartWithoutAxes cwoa,Pie pie,DataPointHints[] dpha,double[] da,Palette pa) throws ChartException {
  this.pa=pa;
  this.pie=pie;
  this.cComp=pie.getRunTimeContext().getState(StateKey.CHART_COMPUTATION_KEY);
  ps=(PieSeries)pie.getSeries();
  sExplosionExpression=ps.getExplosionExpression();
  dExplosion=ps.getExplosion() * pie.getDeviceScale();
  dThickness=((cwoa.getDimension() == ChartDimension.TWO_DIMENSIONAL_LITERAL) ? 0 : cwoa.getSeriesThickness()) * pie.getDeviceScale();
  ratio=ps.isSetRatio() ? ps.getRatio() : 1;
  rotation=ps.isSetRotation() ? ps.getRotation() : 0;
  liaLL=ps.getLeaderLineAttributes();
  if (ps.getLeaderLineAttributes().isVisible()) {
    dLeaderLength=ps.getLeaderLineLength() * pie.getDeviceScale();
  }
 else {
    dLeaderLength=0;
  }
  liaEdges=goFactory.createLineAttributes(goFactory.BLACK(),LineStyle.SOLID_LITERAL,1);
  bPaletteByCategory=(cwoa.getLegend().getItemType() == LegendItemType.CATEGORIES_LITERAL);
  lpDataPoint=ps.getLabelPosition();
  lpSeriesTitle=ps.getTitlePosition();
  laSeriesTitle=goFactory.copyOf(ps.getTitle());
  laSeriesTitle.getCaption().setValue(pie.getRunTimeContext().externalizedMessage(String.valueOf(ps.getSeriesIdentifier())));
  laSeriesTitle.getCaption().getFont().setAlignment(pie.switchTextAlignment(laSeriesTitle.getCaption().getFont().getAlignment()));
  final AbstractScriptHandler sh=pie.getRunTimeContext().getScriptHandler();
  ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_SERIES_TITLE,ps,laSeriesTitle,pie.getRunTimeContext().getScriptContext());
  pie.getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_SERIES_TITLE,laSeriesTitle);
  lls=ps.getLeaderLineStyle();
  bMinSliceDefined=cwoa.isSetMinSlice();
  dMinSlice=cwoa.getMinSlice();
  bPercentageMinSlice=cwoa.isMinSlicePercent();
  double dTotal=0;
  orginalSliceCount=da.length;
  for (int i=0; i < da.length; i++) {
    if (da[i] < 0) {
      dTotal-=da[i];
    }
 else     if (!Double.isNaN(da[i])) {
      dTotal+=da[i];
    }
  }
  if (bMinSliceDefined) {
    if (bPercentageMinSlice) {
      dAbsoluteMinSlice=dMinSlice * dTotal / 100d;
    }
 else {
      dAbsoluteMinSlice=dMinSlice;
    }
    double residualPos=0;
    double residualNeg=0;
    DataPointHints dphPos=null;
    DataPointHints dphNeg=null;
    for (int i=0; i < da.length; i++) {
      if (Double.isNaN(da[i])) {
        continue;
      }
      if (Math.abs(da[i]) >= Math.abs(dAbsoluteMinSlice)) {
        pieSliceList.add(new PieSlice(da[i],dpha[i],i));
      }
 else {
        if (da[i] >= 0) {
          residualPos+=da[i];
          if (dphPos == null) {
            dphPos=dpha[i].getVirtualCopy();
          }
 else {
            dphPos.accumulate(dpha[i].getBaseValue(),dpha[i].getOrthogonalValue(),dpha[i].getSeriesValue(),dpha[i].getPercentileOrthogonalValue());
          }
        }
 else {
          residualNeg+=da[i];
          if (dphNeg == null) {
            dphNeg=dpha[i].getVirtualCopy();
          }
 else {
            dphNeg.accumulate(dpha[i].getBaseValue(),dpha[i].getOrthogonalValue(),dpha[i].getSeriesValue(),dpha[i].getPercentileOrthogonalValue());
          }
        }
      }
    }
    String extSliceLabel=pie.getRunTimeContext().externalizedMessage(cwoa.getMinSliceLabel());
    if (dphPos != null) {
      dphPos.setBaseValue(extSliceLabel);
      dphPos.setIndex(orginalSliceCount);
      pieSliceList.add(new PieSlice(residualPos,dphPos,orginalSliceCount));
      bMinSliceApplied=true;
    }
    if (dphNeg != null) {
      dphNeg.setBaseValue(extSliceLabel);
      dphNeg.setIndex(orginalSliceCount);
      pieSliceList.add(new PieSlice(residualNeg,dphNeg,orginalSliceCount));
      bMinSliceApplied=true;
    }
  }
 else {
    for (int i=0; i < da.length; i++) {
      if (Double.isNaN(da[i])) {
        continue;
      }
      pieSliceList.add(new PieSlice(da[i],dpha[i],i));
    }
  }
  double startAngle=rotation;
  double originalStartAngle=rotation;
  if (dTotal == 0) {
    dTotal=1;
  }
  if (ps.isClockwise()) {
    Collections.reverse(pieSliceList);
  }
  PieSlice slice=null;
  double totalAngle=0d;
  for (Iterator iter=pieSliceList.iterator(); iter.hasNext(); ) {
    slice=(PieSlice)iter.next();
    double length=(Math.abs(slice.getPrimitiveValue()) / dTotal) * 360d;
    double percentage=(slice.getPrimitiveValue() / dTotal) * 100d;
    slice.setStartAngle(startAngle);
    slice.setOriginalStartAngle(originalStartAngle);
    slice.setSliceLength(length);
    slice.setPercentage(percentage);
    startAngle+=length + MIN_DOUBLE;
    originalStartAngle+=length;
    startAngle=wrapAngle(startAngle);
    originalStartAngle=wrapAngle(originalStartAngle);
    totalAngle+=length;
  }
  if (totalAngle > 0 && 360 - totalAngle > 0.001) {
    slice.setSliceLength(360 - slice.getStartAngle());
  }
  initExploded();
}