Program: 69662
Project: 69662
Buggy source:
/** 
 * Renders all blocks using the appropriate block z-order and the containment hierarchy.
 * @param bo
 */
public void render(Map<Series,LegendItemRenderingHints> htRenderers,Bounds bo) throws ChartException {
  final boolean bFirstInSequence=(iSeriesIndex == 0);
  final boolean bLastInSequence=(iSeriesIndex == iSeriesCount - 1);
  boolean bStarted=bFirstInSequence;
  Block bl=cm.getBlock();
  final Enumeration<Block> e=bl.children(true);
  final BlockGenerationEvent bge=new BlockGenerationEvent(this);
  final IDeviceRenderer idr=getDevice();
  final AbstractScriptHandler sh=getRunTimeContext().getScriptHandler();
  if (bFirstInSequence) {
    ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
    bge.updateBlock(bl);
    renderChartBlock(idr,bl,StructureSource.createChartBlock(bl));
    ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
  }
  while (e.hasMoreElements()) {
    bl=e.nextElement();
    bge.updateBlock(bl);
    if (bl instanceof Plot) {
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
      renderPlot(ir,(Plot)bl);
      ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
      if (bFirstInSequence && !bLastInSequence) {
        break;
      }
      if (!bStarted) {
        bStarted=true;
      }
    }
 else     if (bl instanceof TitleBlock && bStarted) {
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
      renderTitle(ir,(TitleBlock)bl);
      ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
    }
 else     if (bl instanceof LabelBlock && bStarted) {
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
      renderLabel(ir,bl,StructureSource.createUnknown(bl));
      ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
    }
 else     if (bl instanceof Legend && bStarted && bLastInSequence) {
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
      renderLegend(idr,(Legend)bl,htRenderers);
      ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
    }
 else     if (bStarted) {
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
      renderBlock(ir,bl,StructureSource.createUnknown(bl));
      ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
    }
  }
  if (bLastInSequence) {
    try {
      fDeferredCacheManager.flushAll();
    }
 catch (    ChartException ex) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,ex);
    }
  }
}

Fixed version (ground truth):
/** 
 * Renders all blocks using the appropriate block z-order and the containment hierarchy.
 * @param bo
 */
public void render(Map<Series,LegendItemRenderingHints> htRenderers,Bounds bo) throws ChartException {
  final boolean bFirstInSequence=(iSeriesIndex == 0);
  final boolean bLastInSequence=(iSeriesIndex == iSeriesCount - 1);
  boolean bStarted=bFirstInSequence;
  Block bl=cm.getBlock();
  final Enumeration<Block> e=bl.children(true);
  final BlockGenerationEvent bge=new BlockGenerationEvent(this);
  final IDeviceRenderer idr=getDevice();
  final AbstractScriptHandler<?> sh=getRunTimeContext().getScriptHandler();
  if (bFirstInSequence) {
    ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
    bge.updateBlock(bl);
    renderChartBlock(idr,bl,StructureSource.createChartBlock(bl));
    ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
  }
  while (e.hasMoreElements()) {
    bl=e.nextElement();
    bge.updateBlock(bl);
    if (bl instanceof Plot) {
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
      renderPlot(ir,(Plot)bl);
      ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
      if (bFirstInSequence && !bLastInSequence) {
        break;
      }
      if (!bStarted) {
        bStarted=true;
      }
    }
 else     if (bl instanceof TitleBlock && bStarted) {
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
      renderTitle(ir,(TitleBlock)bl);
      ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
    }
 else     if (bl instanceof LabelBlock && bStarted) {
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
      renderLabel(ir,bl,StructureSource.createUnknown(bl));
      ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
    }
 else     if (bl instanceof Legend && bStarted && bLastInSequence) {
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
      renderLegend(idr,(Legend)bl,htRenderers);
      ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
    }
 else     if (bStarted) {
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_BLOCK,bl);
      renderBlock(ir,bl,StructureSource.createUnknown(bl));
      ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_BLOCK,bl,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_BLOCK,bl);
    }
  }
  if (bLastInSequence) {
    try {
      fDeferredCacheManager.flushAll();
    }
 catch (    ChartException ex) {
      throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,ex);
    }
  }
}