Program: 68474
Project: 68474
Buggy source:
public int open(final ExtendedItemHandle eih){
  if (iInstanceCount > 0) {
    return Window.CANCEL;
  }
  iInstanceCount++;
  if (ChartCubeUtil.isAxisChart(eih)) {
    DesignElementHandle hostChart=eih.getElementProperty(ChartReportItemConstants.PROPERTY_HOST_CHART);
    this.extendedHandle=(ExtendedItemHandle)hostChart;
  }
 else {
    this.extendedHandle=eih;
  }
  ReportDataServiceProvider dataProvider=null;
  ChartLivePreviewThread livePreviewThread=null;
  try {
    IReportItem item=null;
    try {
      item=extendedHandle.getReportItem();
      if (item == null) {
        extendedHandle.loadExtendedElement();
        item=extendedHandle.getReportItem();
      }
    }
 catch (    ExtendedElementException exception) {
      logger.log(exception);
    }
    if (item == null) {
      logger.log(ILogger.ERROR,Messages.getString("String_Node_Str"));
      return Window.CANCEL;
    }
    final CommandStack commandStack=extendedHandle.getRoot().getCommandStack();
    final String TRANS_NAME=org.eclipse.birt.chart.reportitem.i18n.Messages.getString("String_Node_Str");
    commandStack.startTrans(TRANS_NAME);
    final ChartReportItemImpl crii=((ChartReportItemImpl)item);
    final Chart cm=(Chart)crii.getProperty(ChartReportItemConstants.PROPERTY_CHART);
    final Chart cmClone=(cm == null) ? null : cm.copyInstance();
    if (cmClone != null) {
      maintainCompatibility(cmClone);
    }
    final Object[] applyData=new Object[3];
    Shell parentShell=null;
    if (PlatformUI.isWorkbenchRunning()) {
      parentShell=PlatformUI.getWorkbench().getDisplay().getActiveShell();
    }
    final ChartWizard chartBuilder=new ChartWizard(parentShell);
    dataProvider=new ReportDataServiceProvider(extendedHandle);
    ChartReportItemUIFactory uiFactory=ChartReportItemUIFactory.instance();
    IChartDataSheet dataSheet=uiFactory.createDataSheet(extendedHandle,dataProvider);
    final ChartWizardContext context=uiFactory.createWizardContext(cmClone,this,dataProvider,dataSheet);
    this.wizardContext=context;
    livePreviewThread=new ChartLivePreviewThread(dataProvider);
    livePreviewThread.start();
    context.setLivePreviewThread(livePreviewThread);
    dataProvider.setWizardContext(context);
    if (dataProvider.checkState(IDataServiceProvider.PART_CHART)) {
      context.setEnabled(ChartUIConstants.SUBTASK_AXIS,false);
      context.setEnabled(ChartUIConstants.SUBTASK_AXIS_X,false);
      context.setEnabled(ChartUIConstants.SUBTASK_AXIS_Y,false);
      context.setEnabled(ChartUIConstants.SUBTASK_AXIS_Z,false);
      context.setEnabled(ChartUIConstants.SUBTASK_LEGEND,false);
      context.setEnabled(ChartUIConstants.SUBTASK_TITLE,false);
      context.setEnabled(ChartUIConstants.TYPE_PIE,false);
      context.setEnabled(ChartUIConstants.TYPE_METER,false);
      context.setEnabled(ChartUIConstants.TYPE_STOCK,false);
      context.setEnabled(ChartUIConstants.TYPE_BUBBLE,false);
      context.setEnabled(ChartUIConstants.TYPE_DIFFERENCE,false);
      context.setEnabled(ChartUIConstants.TYPE_GANTT,false);
    }
    chartBuilder.addCustomButton(new ApplyButtonHandler(chartBuilder){
      public void run(){
        super.run();
        applyData[0]=context.getModel().copyInstance();
        applyData[1]=context.getOutputFormat();
        applyData[2]=context.isInheritColumnsOnly();
        commandStack.commit();
        commandStack.startTrans(TRANS_NAME);
      }
    }
);
    context.setRtL(crii.isLayoutDirectionRTL());
    context.setTextRtL(extendedHandle.isDirectionRTL());
    context.setResourceFinder(crii);
    context.setExternalizer(crii);
    Object of=extendedHandle.getProperty(ChartReportItemConstants.PROPERTY_OUTPUT);
    if (of instanceof String) {
      if (of.equals("String_Node_Str")) {
        context.setOutputFormat("String_Node_Str");
      }
 else {
        context.setOutputFormat((String)of);
      }
    }
    context.setInheritColumnsOnly(extendedHandle.getBooleanProperty(ChartReportItemConstants.PROPERTY_INHERIT_COLUMNS));
    context.setExtendedItem(extendedHandle);
    context.setProcessor(new ChartReportStyleProcessor(extendedHandle,false));
    ChartAdapter.beginIgnoreNotifications();
    if (dataProvider.checkState(IDataServiceProvider.SHARE_CHART_QUERY)) {
      dataProvider.update(ChartUIConstants.COPY_SERIES_DEFINITION,null);
    }
    ChartWizard.clearExceptions();
    if (eih.getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_NONE && eih.getContainer() instanceof ModuleHandle) {
      String[] dataSets=dataProvider.getAllDataSets();
      if (dataProvider.getAllDataCubes().length == 0 && dataSets.length == 1) {
        dataProvider.setDataSet(dataSets[0]);
      }
    }
    context.setActionEvaluator(new BIRTActionEvaluator());
    ChartAdapter.endIgnoreNotifications();
    isChartWizardOpen=true;
    ChartWizardContext contextResult=(ChartWizardContext)chartBuilder.open(null,taskId,context);
    isChartWizardOpen=false;
    if (contextResult != null && contextResult.getModel() != null) {
      updateModel(extendedHandle,chartBuilder,crii,cm,contextResult.getModel(),contextResult.getOutputFormat(),contextResult.isInheritColumnsOnly());
      if (dataProvider.isPartChart()) {
        ChartXTabUIUtil.updateXTabForAxis(ChartCubeUtil.getXtabContainerCell(extendedHandle),extendedHandle,ChartXTabUIUtil.isTransposedChartWithAxes(cm),(ChartWithAxes)contextResult.getModel());
      }
      commandStack.commit();
      return Window.OK;
    }
 else     if (applyData[0] != null) {
      commandStack.rollback();
      updateModel(extendedHandle,chartBuilder,crii,cm,(Chart)applyData[0],(String)applyData[1],(Boolean)applyData[2]);
      if (dataProvider.isPartChart()) {
        commandStack.startTrans(TRANS_NAME);
        ChartXTabUIUtil.updateXTabForAxis(ChartCubeUtil.getXtabContainerCell(extendedHandle),extendedHandle,ChartXTabUIUtil.isTransposedChartWithAxes(cm),(ChartWithAxes)applyData[0]);
        commandStack.commit();
      }
      return Window.OK;
    }
    commandStack.rollback();
    return Window.CANCEL;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
 finally {
    iInstanceCount--;
    this.extendedHandle=null;
    isChartWizardOpen=false;
    if (livePreviewThread != null) {
      livePreviewThread.end();
    }
  }
}

Fixed version (ground truth):
public int open(final ExtendedItemHandle eih){
  if (iInstanceCount > 0) {
    return Window.CANCEL;
  }
  iInstanceCount++;
  if (ChartCubeUtil.isAxisChart(eih)) {
    DesignElementHandle hostChart=eih.getElementProperty(ChartReportItemConstants.PROPERTY_HOST_CHART);
    this.extendedHandle=(ExtendedItemHandle)hostChart;
  }
 else {
    this.extendedHandle=eih;
  }
  ReportDataServiceProvider dataProvider=null;
  ChartLivePreviewThread livePreviewThread=null;
  try {
    IReportItem item=null;
    try {
      item=extendedHandle.getReportItem();
      if (item == null) {
        extendedHandle.loadExtendedElement();
        item=extendedHandle.getReportItem();
      }
    }
 catch (    ExtendedElementException exception) {
      logger.log(exception);
    }
    if (item == null) {
      logger.log(ILogger.ERROR,Messages.getString("String_Node_Str"));
      return Window.CANCEL;
    }
    final CommandStack commandStack=extendedHandle.getRoot().getCommandStack();
    final String TRANS_NAME=org.eclipse.birt.chart.reportitem.i18n.Messages.getString("String_Node_Str");
    commandStack.startTrans(TRANS_NAME);
    final ChartReportItemImpl crii=((ChartReportItemImpl)item);
    final Chart cm=(Chart)crii.getProperty(ChartReportItemConstants.PROPERTY_CHART);
    final Chart cmClone=(cm == null) ? null : cm.copyInstance();
    if (cmClone != null) {
      maintainCompatibility(cmClone);
    }
    final Object[] applyData=new Object[3];
    Shell parentShell=null;
    if (PlatformUI.isWorkbenchRunning()) {
      parentShell=PlatformUI.getWorkbench().getDisplay().getActiveShell();
    }
    final ChartWizard chartBuilder=new ChartWizard(parentShell);
    dataProvider=new ReportDataServiceProvider(extendedHandle);
    ChartReportItemUIFactory uiFactory=ChartReportItemUIFactory.instance();
    IChartDataSheet dataSheet=uiFactory.createDataSheet(extendedHandle,dataProvider);
    final ChartWizardContext context=uiFactory.createWizardContext(cmClone,this,dataProvider,dataSheet);
    this.wizardContext=context;
    livePreviewThread=new ChartLivePreviewThread(dataProvider);
    livePreviewThread.start();
    context.setLivePreviewThread(livePreviewThread);
    dataProvider.setWizardContext(context);
    if (dataProvider.checkState(IDataServiceProvider.PART_CHART)) {
      context.setEnabled(ChartUIConstants.SUBTASK_AXIS,false);
      context.setEnabled(ChartUIConstants.SUBTASK_AXIS_X,false);
      context.setEnabled(ChartUIConstants.SUBTASK_AXIS_Y,false);
      context.setEnabled(ChartUIConstants.SUBTASK_AXIS_Z,false);
      context.setEnabled(ChartUIConstants.SUBTASK_LEGEND,false);
      context.setEnabled(ChartUIConstants.SUBTASK_TITLE,false);
      context.setEnabled(ChartUIConstants.TYPE_PIE,false);
      context.setEnabled(ChartUIConstants.TYPE_METER,false);
      context.setEnabled(ChartUIConstants.TYPE_STOCK,false);
      context.setEnabled(ChartUIConstants.TYPE_BUBBLE,false);
      context.setEnabled(ChartUIConstants.TYPE_DIFFERENCE,false);
      context.setEnabled(ChartUIConstants.TYPE_GANTT,false);
    }
    chartBuilder.addCustomButton(new ApplyButtonHandler(chartBuilder){
      public void run(){
        super.run();
        applyData[0]=context.getModel().copyInstance();
        applyData[1]=context.getOutputFormat();
        applyData[2]=context.isInheritColumnsOnly();
        commandStack.commit();
        commandStack.startTrans(TRANS_NAME);
      }
    }
);
    context.setRtL(crii.isLayoutDirectionRTL());
    context.setTextRtL(extendedHandle.isDirectionRTL());
    context.setResourceFinder(crii);
    context.setExternalizer(crii);
    Object of=extendedHandle.getProperty(ChartReportItemConstants.PROPERTY_OUTPUT);
    if (of instanceof String) {
      if (of.equals("String_Node_Str")) {
        context.setOutputFormat("String_Node_Str");
      }
 else {
        context.setOutputFormat((String)of);
      }
    }
    context.setInheritColumnsOnly(extendedHandle.getBooleanProperty(ChartReportItemConstants.PROPERTY_INHERIT_COLUMNS));
    context.setExtendedItem(extendedHandle);
    context.setProcessor(new ChartReportStyleProcessor(extendedHandle,false));
    ChartAdapter.beginIgnoreNotifications();
    if (dataProvider.checkState(IDataServiceProvider.SHARE_CHART_QUERY)) {
      dataProvider.update(ChartUIConstants.COPY_SERIES_DEFINITION,null);
    }
    ChartWizard.clearExceptions();
    context.setActionEvaluator(new BIRTActionEvaluator());
    ChartAdapter.endIgnoreNotifications();
    isChartWizardOpen=true;
    ChartWizardContext contextResult=(ChartWizardContext)chartBuilder.open(null,taskId,context);
    isChartWizardOpen=false;
    if (contextResult != null && contextResult.getModel() != null) {
      updateModel(extendedHandle,chartBuilder,crii,cm,contextResult.getModel(),contextResult.getOutputFormat(),contextResult.isInheritColumnsOnly());
      if (dataProvider.isPartChart()) {
        ChartXTabUIUtil.updateXTabForAxis(ChartCubeUtil.getXtabContainerCell(extendedHandle),extendedHandle,ChartXTabUIUtil.isTransposedChartWithAxes(cm),(ChartWithAxes)contextResult.getModel());
      }
      commandStack.commit();
      return Window.OK;
    }
 else     if (applyData[0] != null) {
      commandStack.rollback();
      updateModel(extendedHandle,chartBuilder,crii,cm,(Chart)applyData[0],(String)applyData[1],(Boolean)applyData[2]);
      if (dataProvider.isPartChart()) {
        commandStack.startTrans(TRANS_NAME);
        ChartXTabUIUtil.updateXTabForAxis(ChartCubeUtil.getXtabContainerCell(extendedHandle),extendedHandle,ChartXTabUIUtil.isTransposedChartWithAxes(cm),(ChartWithAxes)applyData[0]);
        commandStack.commit();
      }
      return Window.OK;
    }
    commandStack.rollback();
    return Window.CANCEL;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
 finally {
    iInstanceCount--;
    this.extendedHandle=null;
    isChartWizardOpen=false;
    if (livePreviewThread != null) {
      livePreviewThread.end();
    }
  }
}