nus-yam/ex-repair huggingface dataset:
Program: 71747
Project: 71747
Buggy source:
/** 
 * Parse a date/time string.
 * @param source
 * @return
 * @throws ParseException
 */
public static Date parse(String source) throws BirtException, ParseException {
  if (source == null || source.trim().length() == 0) {
    return null;
  }
  Date resultDate=null;
  source=cleanDate(source);
  Object simpleDateFormatter=DateFormatFactory.getPatternInstance(PatternKey.getPatterKey(source));
  if (simpleDateFormatter != null) {
    try {
      resultDate=((SimpleDateFormat)simpleDateFormatter).parse(source);
      return resultDate;
    }
 catch (    ParseException e1) {
    }
  }
  if (resultDate == null) {
    throw new ParseException("String_Node_Str" + source,0);
  }
  return resultDate;
}

Fixed version (ground truth):
/** 
 * Parse a date/time string.
 * @param source
 * @return
 * @throws ParseException
 */
public static Date parse(String source,TimeZone timeZone) throws BirtException, ParseException {
  if (source == null || source.trim().length() == 0) {
    return null;
  }
  Date resultDate=null;
  source=cleanDate(source);
  Object simpleDateFormatter=DateFormatFactory.getPatternInstance(PatternKey.getPatterKey(source));
  if (simpleDateFormatter != null) {
    SimpleDateFormat dateFormat=(SimpleDateFormat)simpleDateFormatter;
    TimeZone savedTimeZone=null;
    try {
      if (timeZone != null) {
        savedTimeZone=dateFormat.getTimeZone();
        dateFormat.setTimeZone(timeZone);
      }
      resultDate=dateFormat.parse(source);
      return resultDate;
    }
 catch (    ParseException e1) {
    }
 finally {
      if (savedTimeZone != null)       dateFormat.setTimeZone(savedTimeZone);
    }
  }
  if (resultDate == null) {
    throw new ParseException("String_Node_Str" + source,0);
  }
  return resultDate;
}
Program: 71748
Project: 71748
Buggy source:
/** 
 * Creates a DataEngine context in the provided mode, using the provided top level scope. Also sets the handle of the report design being executed. 
 * @param mode Data Session mode. Can be MODE_GENERATION, MODE_PRESENTATION or MODE_DIRECT_PRESENTATION
 * @param moduleHandle If not null, this report module is used to look up data setand data source definition when executing queries.
 * @param scriptContext
 * @param classLoader
 * @throws AdapterException
 */
public DataSessionContext(int mode,ModuleHandle moduleHandle,ScriptContext scriptContext,ClassLoader classLoader) throws AdapterException {
  if (!(mode == MODE_GENERATION || mode == MODE_PRESENTATION || mode == MODE_DIRECT_PRESENTATION || mode == MODE_UPDATE))   throw new AdapterException(ResourceConstants.ADAPTER_INVALID_MODE,new Integer(mode));
  this.mode=mode;
  this.hasExternalScope=topScope != null;
  this.moduleHandle=moduleHandle;
  this.appClassLoader=classLoader;
  this.sContext=scriptContext;
  this.topScope=scriptContext.getScope();
}

Fixed version (ground truth):
/** 
 * Creates a DataEngine context in the provided mode, using the provided top level scope. Also sets the handle of the report design being executed. 
 * @param mode Data Session mode. Can be MODE_GENERATION, MODE_PRESENTATION or MODE_DIRECT_PRESENTATION
 * @param moduleHandle If not null, this report module is used to look up data setand data source definition when executing queries.
 * @param scriptContext
 * @param classLoader
 * @throws AdapterException
 */
public DataSessionContext(int mode,ModuleHandle moduleHandle,ScriptContext scriptContext,ClassLoader classLoader) throws AdapterException {
  if (!(mode == MODE_GENERATION || mode == MODE_PRESENTATION || mode == MODE_DIRECT_PRESENTATION || mode == MODE_UPDATE))   throw new AdapterException(ResourceConstants.ADAPTER_INVALID_MODE,new Integer(mode));
  this.mode=mode;
  this.hasExternalScope=topScope != null;
  this.moduleHandle=moduleHandle;
  this.appClassLoader=classLoader;
  if (scriptContext == null) {
    scriptContext=new ScriptContext();
    scriptContext.enterScope(this.getTopScope());
  }
  this.sContext=scriptContext;
  this.topScope=scriptContext.getScope();
}
Program: 71749
Project: 71749
Buggy source:
/** 
 * Edits the selected binding of table.
 * @param bindingIndex
 */
private void editSelectedBinding(int bindingIndex){
  if (!btnEdit.isEnabled())   return;
  ComputedColumnHandle bindingHandle=null;
  if (bindingIndex > -1) {
    bindingHandle=(ComputedColumnHandle)(DEUtil.getBindingHolder(inputElement)).getColumnBindings().getAt(bindingIndex);
  }
  if (bindingHandle == null)   return;
  String bindingName=bindingHandle.getName();
  DataColumnBindingDialog dialog=new DataColumnBindingDialog(false);
  dialog.setInput(inputElement,bindingHandle);
  dialog.setExpressionProvider(expressionProvider);
  if (dialog.open() == Dialog.OK) {
    if (bindingTable != null)     bindingTable.getTable().setSelection(bindingIndex);
    if (selectedColumnName != null && selectedColumnName.equals(bindingName))     selectedColumnName=bindingHandle.getName();
  }
}

Fixed version (ground truth):
/** 
 * Edits the selected binding of table.
 * @param bindingIndex
 */
private void editSelectedBinding(int bindingIndex){
  if (!btnEdit.isEnabled())   return;
  ComputedColumnHandle bindingHandle=null;
  if (bindingIndex > -1) {
    bindingHandle=(ComputedColumnHandle)(DEUtil.getBindingHolder(inputElement)).getColumnBindings().getAt(bindingIndex);
  }
  if (bindingHandle == null)   return;
  String bindingName=bindingHandle.getName();
  DataColumnBindingDialog dialog=new DataColumnBindingDialog(false);
  setDialogInput(dialog,bindingHandle);
  dialog.setExpressionProvider(expressionProvider);
  if (dialog.open() == Dialog.OK) {
    if (bindingTable != null)     bindingTable.getTable().setSelection(bindingIndex);
    if (selectedColumnName != null && selectedColumnName.equals(bindingName))     selectedColumnName=bindingHandle.getName();
  }
}
Program: 71751
Project: 71751
Buggy source:
public ExtensionClassMethod(IMethodInfo method){
  this.method=method;
}

Fixed version (ground truth):
public ExtensionClassMethod(IMethodInfo method){
  this.method=method;
  IClassInfo typeInfo=method.getClassReturnType();
  if (typeInfo != null) {
    returnType=new ExtensionClassJSObject(typeInfo);
  }
}
Program: 71752
Project: 71752
Buggy source:
public JSObjectMetaData getReturn(){
  IClassInfo rtInfo=method.getClassReturnType();
  if (rtInfo != null) {
    return new ExtensionClassJSObject(method.getClassReturnType());
  }
  return null;
}

Fixed version (ground truth):
public JSObjectMetaData getReturn(){
  return returnType;
}
Program: 71753
Project: 71753
Buggy source:
public ExtensionClassField(IMemberInfo field){
  this.field=field;
  this.typeName=field.getDataType();
  try {
    this.type=JSSyntaxContext.getJavaClassMeta(field.getDataType());
  }
 catch (  ClassNotFoundException e) {
  }
}

Fixed version (ground truth):
public ExtensionClassField(IMemberInfo field){
  this.field=field;
  this.typeName=field.getDataType();
  IClassInfo typeInfo=field.getClassType();
  if (typeInfo != null) {
    type=new ExtensionClassJSObject(typeInfo);
  }
}
Program: 71754
Project: 71754
Buggy source:
protected void initializeScriptContext(Context cx,Scriptable scope){
  WrapFactory factory=new WrapFactory(){
    protected IJavascriptWrapper coreWrapper=new CoreJavaScriptWrapper();
    /** 
 * wrapper an java object to javascript object.
 */
    public Object wrap(    Context cx,    Scriptable scope,    Object obj,    Class staticType){
      Object object=coreWrapper.wrap(cx,scope,obj,staticType);
      if (object != obj) {
        return object;
      }
      return super.wrap(cx,scope,obj,staticType);
    }
  }
;
  factory.setJavaPrimitiveWrap(false);
  scriptContext.getContext().setWrapFactory(factory);
  new CoreJavaScriptInitializer().initialize(cx,scope);
}

Fixed version (ground truth):
protected void initializeScriptContext(Context cx,Scriptable scope){
  WrapFactory factory=new WrapFactory(){
    protected IJavascriptWrapper coreWrapper=new CoreJavaScriptWrapper();
    /** 
 * wrapper an java object to javascript object.
 */
    public Object wrap(    Context cx,    Scriptable scope,    Object obj,    Class staticType){
      Object object=coreWrapper.wrap(cx,scope,obj,staticType);
      if (object != obj) {
        return object;
      }
      return super.wrap(cx,scope,obj,staticType);
    }
  }
;
  scriptContext.getContext().setWrapFactory(factory);
  new CoreJavaScriptInitializer().initialize(cx,scope);
}
Program: 71755
Project: 71755
Buggy source:
public boolean isEmpty() throws BirtException {
  return exprManager.getBindingExprs().isEmpty();
}

Fixed version (ground truth):
public boolean isEmpty() throws BirtException {
  return false;
}
Program: 71756
Project: 71756
Buggy source:
public boolean isEmpty() throws BirtException {
  return false;
}

Fixed version (ground truth):
public boolean isEmpty() throws BirtException {
  return exprManager.getBindingExprs().isEmpty();
}
Program: 71757
Project: 71757
Buggy source:
/** 
 * Calculates the spacing by given container width, text width and horizontal alignment style.
 * @param compWidth Container width.
 * @param textWidth Text width.
 * @return
 * @author bidi_hcg
 */
protected int calculateSpacing(int compWidth,int textWidth){
  int rlt=0;
  String align=BidiAlignmentResolver.resolveAlignment(textAlign,isMirrored());
  if (DesignChoiceConstants.TEXT_ALIGN_LEFT.equals(align) || DesignChoiceConstants.TEXT_ALIGN_JUSTIFY.equals(align)) {
    rlt=0;
  }
 else   if (DesignChoiceConstants.TEXT_ALIGN_CENTER.equals(align)) {
    rlt=(compWidth - textWidth) / 2;
  }
 else   if (DesignChoiceConstants.TEXT_ALIGN_RIGHT.equals(align)) {
    rlt=(compWidth - textWidth);
  }
  return rlt;
}

Fixed version (ground truth):
/** 
 * Calculates the spacing by given container width, text width and horizontal alignment style.
 * @param compWidth Container width.
 * @param textWidth Text width.
 * @return
 * @author bidi_hcg
 */
protected int calculateSpacing(int compWidth,int textWidth){
  int rlt=0;
  String align=BidiAlignmentResolver.resolveAlignment(textAlign,isMirrored());
  if (align == null) {
    if (getDirection() != null) {
      if (getDirection().equals(DesignChoiceConstants.BIDI_DIRECTION_LTR) && isMirrored()) {
        align=DesignChoiceConstants.TEXT_ALIGN_RIGHT;
      }
 else       if (getDirection().equals(DesignChoiceConstants.BIDI_DIRECTION_RTL) && !isMirrored()) {
        align=DesignChoiceConstants.TEXT_ALIGN_RIGHT;
      }
    }
 else {
      if (isMirrored()) {
        align=DesignChoiceConstants.TEXT_ALIGN_RIGHT;
      }
 else {
        align=DesignChoiceConstants.TEXT_ALIGN_LEFT;
      }
    }
  }
  if (DesignChoiceConstants.TEXT_ALIGN_LEFT.equals(align) || DesignChoiceConstants.TEXT_ALIGN_JUSTIFY.equals(align)) {
    rlt=0;
  }
 else   if (DesignChoiceConstants.TEXT_ALIGN_CENTER.equals(align)) {
    rlt=(compWidth - textWidth) / 2;
  }
 else   if (DesignChoiceConstants.TEXT_ALIGN_RIGHT.equals(align)) {
    rlt=(compWidth - textWidth);
  }
  return rlt;
}
Program: 71758
Project: 71758
Buggy source:
/** 
 * @param style
 * @return A new CellEditor style
 * @author bidi_hcg
 */
private int applyBidiStyle(int style){
  boolean rtl=DesignChoiceConstants.BIDI_DIRECTION_RTL.equals(((LabelFigure)getEditPart().getFigure()).getDirection());
  style|=(rtl ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT);
  String align=((LabelFigure)getEditPart().getFigure()).getTextAlign();
  if (IStyle.CSS_CENTER_VALUE.equals(align))   style|=SWT.CENTER;
 else   if (IStyle.CSS_RIGHT_VALUE.equals(align))   style|=(rtl ? SWT.LEFT : SWT.RIGHT);
 else   if (IStyle.CSS_LEFT_VALUE.equals(align))   style|=(rtl ? SWT.RIGHT : SWT.LEFT);
 else {
    boolean mirrored=getEditPart().getFigure().isMirrored();
    style|=(mirrored ^ rtl ? SWT.RIGHT : SWT.LEFT);
  }
  return style;
}

Fixed version (ground truth):
/** 
 * @param style
 * @return A new CellEditor style
 * @author bidi_hcg
 */
private int applyBidiStyle(int style){
  boolean rtl=DesignChoiceConstants.BIDI_DIRECTION_RTL.equals(((LabelFigure)getEditPart().getFigure()).getDirection());
  style|=(rtl ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT);
  String align=((LabelFigure)getEditPart().getFigure()).getTextAlign();
  if (align == null) {
    String direction=((LabelFigure)getEditPart().getFigure()).getDirection();
    boolean isMirrored=getEditPart().getFigure().isMirrored();
    if (direction != null) {
      if (direction.equals(DesignChoiceConstants.BIDI_DIRECTION_LTR) && isMirrored) {
        align=DesignChoiceConstants.TEXT_ALIGN_LEFT;
      }
 else       if (direction.equals(DesignChoiceConstants.BIDI_DIRECTION_RTL) && !isMirrored) {
        align=DesignChoiceConstants.TEXT_ALIGN_RIGHT;
      }
    }
 else {
      if (isMirrored) {
        align=DesignChoiceConstants.TEXT_ALIGN_RIGHT;
      }
 else {
        align=DesignChoiceConstants.TEXT_ALIGN_LEFT;
      }
    }
  }
  if (IStyle.CSS_CENTER_VALUE.equals(align))   style|=SWT.CENTER;
 else   if (IStyle.CSS_RIGHT_VALUE.equals(align))   style|=(rtl ? SWT.LEFT : SWT.RIGHT);
 else   if (IStyle.CSS_LEFT_VALUE.equals(align))   style|=(rtl ? SWT.RIGHT : SWT.LEFT);
 else {
    boolean mirrored=getEditPart().getFigure().isMirrored();
    style|=(mirrored ^ rtl ? SWT.RIGHT : SWT.LEFT);
  }
  return style;
}
Program: 71759
Project: 71759
Buggy source:
private void updateScriptContext(DesignElementHandle handle,String method){
  List args=DEUtil.getDesignElementMethodArgumentsInfo(handle,method);
  JSSyntaxContext context=scriptEditor.getContext();
  context.clear();
  for (Iterator iter=args.iterator(); iter.hasNext(); ) {
    IArgumentInfo element=(IArgumentInfo)iter.next();
    String name=element.getName();
    String type=element.getType();
    if (!context.setVariable(name,type)) {
      context.setVariable(name,element.getClassType());
    }
  }
  if (handle instanceof ExtendedItemHandle) {
    ExtendedItemHandle exHandle=(ExtendedItemHandle)handle;
    List mtds=exHandle.getMethods(method);
    if (mtds != null && mtds.size() > 0) {
      for (int i=0; i < mtds.size(); i++) {
        IMethodInfo mi=(IMethodInfo)mtds.get(i);
        for (Iterator itr=mi.argumentListIterator(); itr.hasNext(); ) {
          IArgumentInfoList ailist=(IArgumentInfoList)itr.next();
          for (Iterator argItr=ailist.argumentsIterator(); argItr.hasNext(); ) {
            IArgumentInfo aiinfo=(IArgumentInfo)argItr.next();
            String argName=aiinfo.getName();
            IClassInfo ci=aiinfo.getClassType();
            if (argName == null || argName.length() == 0) {
              argName=convertToParameterName(ci.getName());
            }
            context.setVariable(argName,ci);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void updateScriptContext(DesignElementHandle handle,String method){
  List args=DEUtil.getDesignElementMethodArgumentsInfo(handle,method);
  JSSyntaxContext context=scriptEditor.getContext();
  context.clear();
  for (Iterator iter=args.iterator(); iter.hasNext(); ) {
    IArgumentInfo element=(IArgumentInfo)iter.next();
    String name=element.getName();
    String type=element.getType();
    if (!context.setVariable(name,type)) {
      context.setVariable(name,element.getClassType());
    }
  }
  Object[] adapters=ElementAdapterManager.getAdapters(handle,IScriptContextProvider.class);
  updateExtensionScriptContext(adapters,context,method,null);
  if (handle instanceof ExtendedItemHandle) {
    ExtendedItemHandle exHandle=(ExtendedItemHandle)handle;
    List mtds=exHandle.getMethods(method);
    if (mtds != null && mtds.size() > 0) {
      for (int i=0; i < mtds.size(); i++) {
        IMethodInfo mi=(IMethodInfo)mtds.get(i);
        for (Iterator itr=mi.argumentListIterator(); itr.hasNext(); ) {
          IArgumentInfoList ailist=(IArgumentInfoList)itr.next();
          for (Iterator argItr=ailist.argumentsIterator(); argItr.hasNext(); ) {
            IArgumentInfo aiinfo=(IArgumentInfo)argItr.next();
            String argName=aiinfo.getName();
            IClassInfo ci=aiinfo.getClassType();
            if (argName == null || argName.length() == 0) {
              argName=convertToParameterName(ci.getName());
            }
            context.setVariable(argName,ci);
          }
        }
        if (mi.getName() != null) {
          updateExtensionScriptContext(adapters,context,method,mi.getName());
        }
      }
    }
  }
}
Program: 71762
Project: 71762
Buggy source:
protected void flushRow(int rowId,int colId,boolean withStart){
  int colCount=layout.getColCount();
  Row row=layout.getRow(rowId);
  IRowContent rowContent=(IRowContent)row.getContent();
  if (withStart) {
    emitter.startRow(rowContent);
  }
  for (int j=colId; j < colCount; j++) {
    Cell cell=row.getCell(j);
    if (cell.getStatus() == Cell.CELL_USED) {
      CellContent content=(CellContent)cell.getContent();
      CellContentWrapper tempCell=new CellContentWrapper(content.cell);
      tempCell.setColumn(cell.getColId());
      tempCell.setRowSpan(cell.getRowSpan());
      tempCell.setColSpan(cell.getColSpan());
      emitter.startCell(tempCell);
      if (content.buffer != null) {
        content.buffer.flush();
      }
      emitter.endCell(tempCell);
    }
    if (cell.getStatus() == Cell.CELL_EMPTY) {
      IReportContent report=rowContent.getReportContent();
      ICellContent cellContent=report.createCellContent();
      cellContent.setParent(rowContent);
      cellContent.setColumn(cell.getColId() + 1);
      cellContent.setRowSpan(cell.getRowSpan());
      cellContent.setColSpan(cell.getColSpan());
      emitter.startCell(cellContent);
      emitter.endCell(cellContent);
    }
  }
  emitter.endRow(rowContent);
}

Fixed version (ground truth):
protected void flushRow(int rowId,int colId,boolean withStart){
  int colCount=layout.getColCount();
  int columnId=layout.getColumnId(colId);
  Row row=layout.getRow(rowId);
  IRowContent rowContent=(IRowContent)row.getContent();
  if (withStart) {
    emitter.startRow(rowContent);
  }
  for (int j=columnId; j < colCount; j++) {
    Cell cell=row.getCell(j);
    if (cell.getStatus() == Cell.CELL_USED) {
      CellContent content=(CellContent)cell.getContent();
      CellContentWrapper tempCell=new CellContentWrapper(content.cell);
      tempCell.setColumn(cell.getColId());
      tempCell.setRowSpan(cell.getRowSpan());
      tempCell.setColSpan(cell.getColSpan());
      emitter.startCell(tempCell);
      if (content.buffer != null) {
        content.buffer.flush();
      }
      emitter.endCell(tempCell);
    }
    if (cell.getStatus() == Cell.CELL_EMPTY) {
      IReportContent report=rowContent.getReportContent();
      ICellContent cellContent=report.createCellContent();
      cellContent.setParent(rowContent);
      cellContent.setColumn(cell.getColId() + 1);
      cellContent.setRowSpan(cell.getRowSpan());
      cellContent.setColSpan(cell.getColSpan());
      emitter.startCell(cellContent);
      emitter.endCell(cellContent);
    }
  }
  emitter.endRow(rowContent);
}
Program: 71763
Project: 71763
Buggy source:
/** 
 * Tests dataType property for column binding
 * @throws Exception
 */
public void testDataTypeInComputedColumn() throws Exception {
  openDesign("String_Node_Str");
  OdaDataSetHandle dataSet=(OdaDataSetHandle)designHandle.findDataSet("String_Node_Str");
  List columns=(List)dataSet.getProperty(SimpleDataSet.COMPUTED_COLUMNS_PROP);
  ComputedColumn computedColumn=(ComputedColumn)columns.get(0);
  assertEquals(DesignChoiceConstants.COLUMN_DATA_TYPE_ANY,computedColumn.getDataType());
  computedColumn=(ComputedColumn)columns.get(1);
  assertEquals(DesignChoiceConstants.COLUMN_DATA_TYPE_STRING,computedColumn.getDataType());
  TableHandle table=(TableHandle)designHandle.findElement("String_Node_Str");
  columns=(List)table.getProperty(IReportItemModel.BOUND_DATA_COLUMNS_PROP);
  computedColumn=(ComputedColumn)columns.get(0);
  assertEquals(DesignChoiceConstants.COLUMN_DATA_TYPE_ANY,computedColumn.getDataType());
  computedColumn=(ComputedColumn)columns.get(1);
  assertEquals(DesignChoiceConstants.COLUMN_DATA_TYPE_STRING,computedColumn.getDataType());
  ScalarParameterHandle param1=(ScalarParameterHandle)designHandle.findParameter("String_Node_Str");
  columns=(List)param1.getProperty(IScalarParameterModel.BOUND_DATA_COLUMNS_PROP);
  computedColumn=(ComputedColumn)columns.get(0);
  assertEquals(DesignChoiceConstants.COLUMN_DATA_TYPE_ANY,computedColumn.getDataType());
  computedColumn=(ComputedColumn)columns.get(1);
  assertEquals(DesignChoiceConstants.COLUMN_DATA_TYPE_STRING,computedColumn.getDataType());
}

Fixed version (ground truth):
/** 
 * Tests dataType property for column binding
 * @throws Exception
 */
public void testDataTypeInComputedColumn() throws Exception {
  openDesign("String_Node_Str");
  OdaDataSetHandle dataSet=(OdaDataSetHandle)designHandle.findDataSet("String_Node_Str");
  List columns=(List)dataSet.getProperty(SimpleDataSet.COMPUTED_COLUMNS_PROP);
  ComputedColumn computedColumn=(ComputedColumn)columns.get(0);
  assertEquals(DesignChoiceConstants.COLUMN_DATA_TYPE_ANY,computedColumn.getDataType());
  computedColumn=(ComputedColumn)columns.get(1);
  assertNull(computedColumn.getDataType());
  TableHandle table=(TableHandle)designHandle.findElement("String_Node_Str");
  columns=(List)table.getProperty(IReportItemModel.BOUND_DATA_COLUMNS_PROP);
  computedColumn=(ComputedColumn)columns.get(0);
  assertEquals(DesignChoiceConstants.COLUMN_DATA_TYPE_ANY,computedColumn.getDataType());
  computedColumn=(ComputedColumn)columns.get(1);
  assertNull(computedColumn.getDataType());
  ScalarParameterHandle param1=(ScalarParameterHandle)designHandle.findParameter("String_Node_Str");
  columns=(List)param1.getProperty(IScalarParameterModel.BOUND_DATA_COLUMNS_PROP);
  computedColumn=(ComputedColumn)columns.get(0);
  assertEquals(DesignChoiceConstants.COLUMN_DATA_TYPE_ANY,computedColumn.getDataType());
  computedColumn=(ComputedColumn)columns.get(1);
  assertNull(computedColumn.getDataType());
}
Program: 71764
Project: 71764
Buggy source:
public void refreshFigure(){
  refreshBorder(getTableAdapter().getHandle(),(BaseBorder)getFigure().getBorder());
  ((SectionBorder)(getFigure().getBorder())).setPaddingInsets(getTableAdapter().getPadding(getFigure().getInsets()));
  refreshBackground((DesignElementHandle)getModel());
  refreshMargin();
  for (Iterator itr=getChildren().iterator(); itr.hasNext(); ) {
    TableCellEditPart fg=(TableCellEditPart)itr.next();
    if (!fg.isDelete()) {
      fg.updateBlankString();
    }
  }
  layoutManagerLayout();
}

Fixed version (ground truth):
public void refreshFigure(){
  checkHelper();
  refreshBorder(getTableAdapter().getHandle(),(BaseBorder)getFigure().getBorder());
  ((SectionBorder)(getFigure().getBorder())).setPaddingInsets(getTableAdapter().getPadding(getFigure().getInsets()));
  refreshBackground((DesignElementHandle)getModel());
  refreshMargin();
  for (Iterator itr=getChildren().iterator(); itr.hasNext(); ) {
    TableCellEditPart fg=(TableCellEditPart)itr.next();
    if (!fg.isDelete()) {
      fg.updateBlankString();
    }
  }
  layoutManagerLayout();
}
Program: 71765
Project: 71765
Buggy source:
private void refreshWorkspace(IReportResourceChangeEvent event){
  if (event != null) {
    Object data=event.getData();
    if (data instanceof IPath) {
      IResource[] res=ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation((IPath)data);
      if (res.length == 0) {
        res=ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation((IPath)data);
        if (res.length == 0) {
          return;
        }
      }
      try {
        final IResource[] targes=res;
        new WorkspaceModifyOperation(){
          protected void execute(          IProgressMonitor monitor) throws CoreException {
            for (            IResource rc : targes) {
              rc.refreshLocal(IResource.DEPTH_INFINITE,null);
            }
          }
        }
.run(null);
      }
 catch (      Exception e) {
        ExceptionHandler.handle(e);
      }
    }
  }
}

Fixed version (ground truth):
private void refreshWorkspace(IReportResourceChangeEvent event){
  if (event != null) {
    Object data=event.getData();
    if (data instanceof IPath) {
      refreshResource((IPath)data);
    }
 else     if (data instanceof IPath[]) {
      for (      IPath path : (IPath[])data) {
        refreshResource(path);
      }
    }
  }
}
Program: 71766
Project: 71766
Buggy source:
public synchronized final void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
  monitor.beginTask(null,IProgressMonitor.UNKNOWN);
  try {
    if (srcFile != null && targetFile != null && srcFile.exists() && !targetFile.exists()) {
      if (renameFile(srcFile,targetFile)) {
        fireResourceChanged(targetFile.getAbsolutePath());
        fireResourceChanged(srcFile.getAbsolutePath());
      }
    }
  }
  finally {
    monitor.done();
  }
}

Fixed version (ground truth):
public synchronized final void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
  monitor.beginTask(null,IProgressMonitor.UNKNOWN);
  try {
    if (srcFile != null && targetFile != null && srcFile.exists() && !targetFile.exists()) {
      if (renameFile(srcFile,targetFile)) {
        fireResourceChanged(targetFile.getAbsolutePath(),srcFile.getAbsolutePath());
      }
    }
  }
  finally {
    monitor.done();
  }
}
Program: 71767
Project: 71767
Buggy source:
/** 
 * Notifies model for the reource chang.
 * @param fileName the resource's file name.
 */
protected void fireResourceChanged(String fileName){
  IReportResourceSynchronizer synchronizer=ReportPlugin.getDefault().getResourceSynchronizerService();
  if (synchronizer != null) {
    synchronizer.notifyResourceChanged(new ReportResourceChangeEvent(viewerPage,Path.fromOSString(fileName),IReportResourceChangeEvent.NewResource));
  }
}

Fixed version (ground truth):
/** 
 * Notifies model for the reource chang.
 * @param fileNames the resource's file name.
 */
protected void fireResourceChanged(String... fileNames){
  if (fileNames == null || fileNames.length == 0) {
    return;
  }
  refreshAll();
  IReportResourceSynchronizer synchronizer=ReportPlugin.getDefault().getResourceSynchronizerService();
  if (synchronizer != null) {
    if (fileNames.length == 1) {
      synchronizer.notifyResourceChanged(new ReportResourceChangeEvent(viewerPage,Path.fromOSString(fileNames[0]),IReportResourceChangeEvent.NewResource));
    }
 else {
      IPath[] paths=new IPath[fileNames.length];
      for (int i=0; i < fileNames.length; i++) {
        paths[i]=Path.fromOSString(fileNames[i]);
      }
      synchronizer.notifyResourceChanged(new ReportResourceChangeEvent(viewerPage,paths,IReportResourceChangeEvent.NewResource));
    }
  }
}
Program: 71768
Project: 71768
Buggy source:
/** 
 * Creates an instance of <copy>IRunnableWithProgress</copy> for renaming the specified source file to the specified target file.
 * @param srcFile the specified source file.
 * @param targetFile the specified target file.
 * @return the instance of <code>IRunnableWithProgress</code>.
 */
protected IRunnableWithProgress createRenameFileRunnable(final File srcFile,final File targetFile){
  return new IRunnableWithProgress(){
    public synchronized final void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      monitor.beginTask(null,IProgressMonitor.UNKNOWN);
      try {
        if (srcFile != null && targetFile != null && srcFile.exists() && !targetFile.exists()) {
          if (renameFile(srcFile,targetFile)) {
            fireResourceChanged(targetFile.getAbsolutePath());
            fireResourceChanged(srcFile.getAbsolutePath());
          }
        }
      }
  finally {
        monitor.done();
      }
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Creates an instance of <copy>IRunnableWithProgress</copy> for renaming the specified source file to the specified target file.
 * @param srcFile the specified source file.
 * @param targetFile the specified target file.
 * @return the instance of <code>IRunnableWithProgress</code>.
 */
protected IRunnableWithProgress createRenameFileRunnable(final File srcFile,final File targetFile){
  return new IRunnableWithProgress(){
    public synchronized final void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      monitor.beginTask(null,IProgressMonitor.UNKNOWN);
      try {
        if (srcFile != null && targetFile != null && srcFile.exists() && !targetFile.exists()) {
          if (renameFile(srcFile,targetFile)) {
            fireResourceChanged(targetFile.getAbsolutePath(),srcFile.getAbsolutePath());
          }
        }
      }
  finally {
        monitor.done();
      }
    }
  }
;
}
Program: 71769
Project: 71769
Buggy source:
protected void initializeScriptContext(Context cx,Scriptable scope){
  scriptContext.getContext().setWrapFactory(new WrapFactory(){
    protected IJavascriptWrapper coreWrapper=new CoreJavaScriptWrapper();
    /** 
 * wrapper an java object to javascript object.
 */
    public Object wrap(    Context cx,    Scriptable scope,    Object obj,    Class staticType){
      Object object=coreWrapper.wrap(cx,scope,obj,staticType);
      if (object != obj) {
        return object;
      }
      return super.wrap(cx,scope,obj,staticType);
    }
  }
);
  new CoreJavaScriptInitializer().initialize(cx,scope);
}

Fixed version (ground truth):
protected void initializeScriptContext(Context cx,Scriptable scope){
  WrapFactory factory=new WrapFactory(){
    protected IJavascriptWrapper coreWrapper=new CoreJavaScriptWrapper();
    /** 
 * wrapper an java object to javascript object.
 */
    public Object wrap(    Context cx,    Scriptable scope,    Object obj,    Class staticType){
      Object object=coreWrapper.wrap(cx,scope,obj,staticType);
      if (object != obj) {
        return object;
      }
      return super.wrap(cx,scope,obj,staticType);
    }
  }
;
  factory.setJavaPrimitiveWrap(false);
  scriptContext.getContext().setWrapFactory(factory);
  new CoreJavaScriptInitializer().initialize(cx,scope);
}
Program: 71770
Project: 71770
Buggy source:
/** 
 * Build the style of foreign content.
 */
public void buildForeignStyle(IForeignContent foreign,StringBuffer styleBuffer,int display){
  IStyle style=foreign.getStyle();
  handleShrink(display,style,foreign.getHeight(),foreign.getWidth(),styleBuffer);
  setDisplayProperty(display,HTMLEmitterUtil.DISPLAY_INLINE_BLOCK,styleBuffer);
  IStyle textComputedStyle=foreign.getComputedStyle();
  if (null != textComputedStyle) {
    AttributeBuilder.buildTextDecoration(styleBuffer,textComputedStyle);
  }
  style=getElementStyle(foreign);
  if (style == null) {
    return;
  }
  AttributeBuilder.buildFont(styleBuffer,style);
  AttributeBuilder.buildBox(styleBuffer,style);
  AttributeBuilder.buildBackground(styleBuffer,style,reportEmitter);
  AttributeBuilder.buildText(styleBuffer,style);
  AttributeBuilder.buildVisual(styleBuffer,style);
  AttributeBuilder.buildBidiDirection(styleBuffer,textComputedStyle);
  String textAlign=style.getTextAlign();
  if (textAlign != null) {
    styleBuffer.append("String_Node_Str");
    styleBuffer.append(textAlign);
    styleBuffer.append("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Build the style of foreign content.
 */
public void buildForeignStyle(IForeignContent foreign,StringBuffer styleBuffer,int display){
  IStyle style=foreign.getStyle();
  handleShrink(display,style,foreign.getHeight(),foreign.getWidth(),styleBuffer);
  setDisplayProperty(display,HTMLEmitterUtil.DISPLAY_INLINE_BLOCK,styleBuffer);
  IStyle textComputedStyle=foreign.getComputedStyle();
  if (null != textComputedStyle) {
    AttributeBuilder.buildTextDecoration(styleBuffer,textComputedStyle);
  }
  String textAlign=style.getTextAlign();
  if (textAlign != null) {
    styleBuffer.append("String_Node_Str");
    styleBuffer.append(textAlign);
    styleBuffer.append("String_Node_Str");
  }
  style=getElementStyle(foreign);
  if (style == null) {
    return;
  }
  AttributeBuilder.buildFont(styleBuffer,style);
  AttributeBuilder.buildBox(styleBuffer,style);
  AttributeBuilder.buildBackground(styleBuffer,style,reportEmitter);
  AttributeBuilder.buildText(styleBuffer,style);
  AttributeBuilder.buildVisual(styleBuffer,style);
  AttributeBuilder.buildBidiDirection(styleBuffer,textComputedStyle);
}
Program: 71771
Project: 71771
Buggy source:
/** 
 * Use a new scope in the script context. The following script is evaluated in the new scope. You must call exitScope to return to the parent scope. The new scope is created automatically if the newScope is null.
 * @param newScope,scope used for following evaluation. null means create a scope automatically.
 * @return the scope used for following evaluation.
 */
public Scriptable enterScope(Scriptable newScope){
  if (newScope == null) {
    newScope=context.newObject(scope);
  }
  newScope.setParentScope(scope);
  scope=newScope;
  sharedScope.setPrototype(scope);
  return newScope;
}

Fixed version (ground truth):
/** 
 * Use a new scope in the script context. The following script is evaluated in the new scope. You must call exitScope to return to the parent scope. The new scope is created automatically if the newScope is null.
 * @param newScope,scope used for following evaluation. null means create a scope automatically.
 * @return the scope used for following evaluation.
 */
public Scriptable enterScope(Scriptable newScope){
  if (newScope == null) {
    newScope=context.newObject(scope);
  }
  newScope.setParentScope(scope);
  scope=newScope;
  sharedScope.setParentScope(scope);
  return newScope;
}
Program: 71772
Project: 71772
Buggy source:
/** 
 * exits from the current scripting scope. Must couple with the enterScope.
 */
public void exitScope(){
  Scriptable protoScope=scope.getParentScope();
  if (protoScope != null)   scope=protoScope;
  sharedScope.setPrototype(scope);
}

Fixed version (ground truth):
/** 
 * exits from the current scripting scope. Must couple with the enterScope.
 */
public void exitScope(){
  Scriptable protoScope=scope.getParentScope();
  if (protoScope != null)   scope=protoScope;
  sharedScope.setParentScope(scope);
}
Program: 71773
Project: 71773
Buggy source:
public DataGenerationEngine(ExecutionContext context,IDocArchiveWriter writer) throws Exception {
  super(context,writer);
  DataSessionContext dteSessionContext=new DataSessionContext(DataSessionContext.MODE_GENERATION,null,context.getSharedScope());
  dteSessionContext.setDocumentWriter(writer);
  DataEngineContext dteEngineContext=dteSessionContext.getDataEngineContext();
  dteEngineContext.setLocale(context.getLocale());
  dteEngineContext.setClassLoader(context.getApplicationClassLoader());
  String tempDir=getTempDir(context);
  if (tempDir != null) {
    dteEngineContext.setTmpdir(tempDir);
  }
  dteSession=DataRequestSession.newSession(dteSessionContext);
  dos=new DataOutputStream(writer.createRandomAccessStream(ReportDocumentConstants.DATA_META_STREAM));
  DteMetaInfoIOUtil.startMetaInfo(dos);
}

Fixed version (ground truth):
public DataGenerationEngine(ExecutionContext context,IDocArchiveWriter writer) throws Exception {
  super(context,writer);
  DataSessionContext dteSessionContext=new DataSessionContext(DataSessionContext.MODE_GENERATION,null,context.getScriptContext(),context.getApplicationClassLoader());
  dteSessionContext.setDocumentWriter(writer);
  DataEngineContext dteEngineContext=dteSessionContext.getDataEngineContext();
  dteEngineContext.setLocale(context.getLocale());
  String tempDir=getTempDir(context);
  if (tempDir != null) {
    dteEngineContext.setTmpdir(tempDir);
  }
  dteSession=DataRequestSession.newSession(dteSessionContext);
  dos=new DataOutputStream(writer.createRandomAccessStream(ReportDocumentConstants.DATA_META_STREAM));
  DteMetaInfoIOUtil.startMetaInfo(dos);
}
Program: 71774
Project: 71774
Buggy source:
public DataInteractiveEngine(ExecutionContext context,IDocArchiveReader reader,IDocArchiveWriter writer) throws Exception {
  super(context);
  DataSessionContext dteSessionContext=new DataSessionContext(DataSessionContext.MODE_UPDATE,null,context.getSharedScope());
  dteSessionContext.setDocumentReader(reader);
  dteSessionContext.setDocumentWriter(writer);
  DataEngineContext dteEngineContext=dteSessionContext.getDataEngineContext();
  dteEngineContext.setLocale(context.getLocale());
  dteEngineContext.setClassLoader(context.getApplicationClassLoader());
  String tempDir=getTempDir(context);
  if (tempDir != null) {
    dteEngineContext.setTmpdir(tempDir);
  }
  dteSession=DataRequestSession.newSession(dteSessionContext);
  loadDteMetaInfo(reader);
  if (writer != null && dos == null) {
    dos=new DataOutputStream(writer.createRandomAccessStream(ReportDocumentConstants.DATA_SNAP_META_STREAM));
    DteMetaInfoIOUtil.startMetaInfo(dos);
  }
}

Fixed version (ground truth):
public DataInteractiveEngine(ExecutionContext context,IDocArchiveReader reader,IDocArchiveWriter writer) throws Exception {
  super(context);
  DataSessionContext dteSessionContext=new DataSessionContext(DataSessionContext.MODE_UPDATE,null,context.getScriptContext(),context.getApplicationClassLoader());
  dteSessionContext.setDocumentReader(reader);
  dteSessionContext.setDocumentWriter(writer);
  DataEngineContext dteEngineContext=dteSessionContext.getDataEngineContext();
  dteEngineContext.setLocale(context.getLocale());
  String tempDir=getTempDir(context);
  if (tempDir != null) {
    dteEngineContext.setTmpdir(tempDir);
  }
  dteSession=DataRequestSession.newSession(dteSessionContext);
  loadDteMetaInfo(reader);
  if (writer != null && dos == null) {
    dos=new DataOutputStream(writer.createRandomAccessStream(ReportDocumentConstants.DATA_SNAP_META_STREAM));
    DteMetaInfoIOUtil.startMetaInfo(dos);
  }
}
Program: 71775
Project: 71775
Buggy source:
public DataPresentationEngine(ExecutionContext context,IDocArchiveReader reader) throws Exception {
  super(context);
  DataSessionContext dteSessionContext=new DataSessionContext(DataSessionContext.MODE_PRESENTATION,null,context.getSharedScope());
  dteSessionContext.setDocumentReader(reader);
  DataEngineContext dteEngineContext=dteSessionContext.getDataEngineContext();
  dteEngineContext.setLocale(context.getLocale());
  dteEngineContext.setClassLoader(context.getApplicationClassLoader());
  String tempDir=getTempDir(context);
  if (tempDir != null) {
    dteEngineContext.setTmpdir(tempDir);
  }
  dteSession=DataRequestSession.newSession(dteSessionContext);
  loadDteMetaInfo(reader);
}

Fixed version (ground truth):
public DataPresentationEngine(ExecutionContext context,IDocArchiveReader reader) throws Exception {
  super(context);
  DataSessionContext dteSessionContext=new DataSessionContext(DataSessionContext.MODE_PRESENTATION,null,context.getScriptContext(),context.getApplicationClassLoader());
  dteSessionContext.setDocumentReader(reader);
  DataEngineContext dteEngineContext=dteSessionContext.getDataEngineContext();
  dteEngineContext.setLocale(context.getLocale());
  String tempDir=getTempDir(context);
  if (tempDir != null) {
    dteEngineContext.setTmpdir(tempDir);
  }
  dteSession=DataRequestSession.newSession(dteSessionContext);
  loadDteMetaInfo(reader);
}
Program: 71776
Project: 71776
Buggy source:
ScriptContext getScriptContext(){
  if (scriptContext == null) {
    initializeScriptContext();
  }
  return this.scriptContext;
}

Fixed version (ground truth):
public ScriptContext getScriptContext(){
  if (scriptContext == null) {
    initializeScriptContext();
  }
  return this.scriptContext;
}
Program: 71777
Project: 71777
Buggy source:
/** 
 * evaluate conditional expression. A conditional expression can have an operator, one LHS expression, and up to two expressions on RHS, i.e., testExpr operator operand1 operand2 or testExpr between 1 20 Now only support comparison between the same data type
 * @param expr the conditional expression to be evaluated
 * @return a boolean value (as an Object)
 */
public Object evaluateCondExpr(IConditionalExpression expr) throws BirtException {
  IScriptExpression testExpr=expr.getExpression();
  ScriptContext scriptContext=getScriptContext();
  if (testExpr == null)   return Boolean.FALSE;
  try {
    return ScriptEvalUtil.evalExpr(expr,scriptContext.getContext(),scriptContext.getScope(),ScriptExpression.defaultID,0);
  }
 catch (  Throwable e) {
    throw new EngineException(MessageConstants.INVALID_EXPRESSION_ERROR,testExpr.getText(),e);
  }
}

Fixed version (ground truth):
/** 
 * evaluate conditional expression. A conditional expression can have an operator, one LHS expression, and up to two expressions on RHS, i.e., testExpr operator operand1 operand2 or testExpr between 1 20 Now only support comparison between the same data type
 * @param expr the conditional expression to be evaluated
 * @return a boolean value (as an Object)
 */
public Object evaluateCondExpr(IConditionalExpression expr) throws BirtException {
  IScriptExpression testExpr=expr.getExpression();
  ScriptContext scriptContext=getScriptContext();
  if (testExpr == null)   return Boolean.FALSE;
  try {
    return ScriptEvalUtil.evalExpr(expr,scriptContext,scriptContext.getScope(),ScriptExpression.defaultID,0);
  }
 catch (  Throwable e) {
    throw new EngineException(MessageConstants.INVALID_EXPRESSION_ERROR,testExpr.getText(),e);
  }
}
Program: 71778
Project: 71778
Buggy source:
/** 
 * create a new scope, use the object to create the curren scope.
 * @param object the "this" object in the new scope
 */
public void newScope(Object object){
  ScriptContext scriptContext=getScriptContext();
  Object jsObject=scriptContext.javaToJs(object);
  if (jsObject instanceof Scriptable) {
    scriptContext.enterScope((Scriptable)jsObject);
  }
 else {
    scriptContext.enterScope();
  }
}

Fixed version (ground truth):
/** 
 * create a new scope, use the object to create the curren scope.
 * @param object the "this" object in the new scope
 */
public void newScope(Object object){
  ScriptContext scriptContext=getScriptContext();
  Object jsObject=scriptContext.javaToJs(object);
  if (jsObject instanceof Scriptable) {
    NativeObject nativeObj=new NativeObject();
    nativeObj.setPrototype((Scriptable)jsObject);
    scriptContext.enterScope(nativeObj);
  }
 else {
    scriptContext.enterScope();
  }
}
Program: 71779
Project: 71779
Buggy source:
protected JSMethodRunner getRunner(Scriptable scope,String type,String name){
  String scopeName=type + "String_Node_Str" + name+ "String_Node_Str";
  runner=new JSMethodRunner(scope,scopeName);
  return runner;
}

Fixed version (ground truth):
protected JSMethodRunner getRunner(Scriptable scope,String type,String name){
  String scopeName=type + "String_Node_Str" + name+ "String_Node_Str";
  runner=new JSMethodRunner(context.getScriptContext(),scope,scopeName);
  return runner;
}
Program: 71780
Project: 71780
Buggy source:
/** 
 * test if the enterScope & exitScope is correct.
 */
public void testScope(){
  context.registerBean("String_Node_Str",new Integer(10));
  context.enterScope();
  context.registerBean("String_Node_Str",new Integer(20));
  Object result=context.eval("String_Node_Str");
  assertEquals(((Number)result).doubleValue(),30.0,Double.MIN_VALUE);
  context.exitScope();
  boolean hasException=false;
  try {
    result=context.eval("String_Node_Str");
  }
 catch (  Exception ex) {
    hasException=true;
  }
  assertTrue(hasException);
  result=context.eval("String_Node_Str");
  assertEquals(((Number)result).doubleValue(),10.0,Double.MIN_VALUE);
}

Fixed version (ground truth):
/** 
 * test if the enterScope & exitScope is correct.
 */
public void testScope(){
  context.registerBean("String_Node_Str",new Integer(10));
  context.enterScope();
  context.registerBean("String_Node_Str",new Integer(20));
  Object result=context.eval("String_Node_Str");
  assertEquals(((Number)result).doubleValue(),30.0,Double.MIN_VALUE);
  context.exitScope();
  boolean hasException=false;
  try {
    result=context.eval("String_Node_Str");
  }
 catch (  Exception ex) {
    hasException=true;
  }
  assertTrue(!hasException);
  result=context.eval("String_Node_Str");
  assertEquals(((Number)result).doubleValue(),10.0,Double.MIN_VALUE);
}
Program: 71781
Project: 71781
Buggy source:
public void activate(){
  super.activate();
  getFigure().setFocusTraversable(false);
}

Fixed version (ground truth):
public void activate(){
  super.activate();
  getFigure().setFocusTraversable(false);
  if (getModel() instanceof ReportDesignHandle) {
    getViewer().setProperty(IReportGraphicConstants.REPORT_BIDIORIENTATION_PROPERTY,((ReportDesignHandle)getModel()).getBidiOrientation());
  }
}
Program: 71782
Project: 71782
Buggy source:
private void locateGroupIcon(TableGroupDesign group){
  GroupHandle groupHandle=(GroupHandle)group.getHandle();
  TableHandle tableHandle=(TableHandle)groupHandle.getContainer();
  String keyExpression=groupHandle.getKeyExpr();
  if (keyExpression == null) {
    return;
  }
  keyExpression=keyExpression.trim();
  BandDesign groupHeader=group.getHeader();
  if (group.getHeader() == null) {
    return;
  }
  String columnBindingExpression=getColumnBinding(tableHandle,keyExpression);
  for (int i=0; i < groupHeader.getContentCount(); i++) {
    RowDesign row=(RowDesign)groupHeader.getContent(i);
    for (int j=0; j < row.getCellCount(); j++) {
      CellDesign cell=row.getCell(j);
      for (int k=0; k < cell.getContentCount(); k++) {
        ReportItemDesign item=cell.getContent(k);
        if (hasExpression(tableHandle,item,keyExpression,columnBindingExpression)) {
          cell.setDisplayGroupIcon(true);
          return;
        }
      }
    }
  }
  RowDesign row=(RowDesign)groupHeader.getContent(0);
  if (null != row) {
    CellDesign cell=row.getCell(0);
    if (null != cell) {
      cell.setDisplayGroupIcon(true);
    }
  }
}

Fixed version (ground truth):
private void locateGroupIcon(TableGroupDesign group){
  GroupHandle groupHandle=(GroupHandle)group.getHandle();
  TableHandle tableHandle=(TableHandle)groupHandle.getContainer();
  String keyExpression=groupHandle.getKeyExpr();
  if (keyExpression == null) {
    return;
  }
  keyExpression=keyExpression.trim();
  BandDesign groupHeader=group.getHeader();
  if (group.getHeader() == null) {
    return;
  }
  CellDesign firstStuffedCell=null;
  String columnBindingExpression=getColumnBinding(tableHandle,keyExpression);
  for (int i=0; i < groupHeader.getContentCount(); i++) {
    RowDesign row=(RowDesign)groupHeader.getContent(i);
    for (int j=0; j < row.getCellCount(); j++) {
      CellDesign cell=row.getCell(j);
      for (int k=0; k < cell.getContentCount(); k++) {
        ReportItemDesign item=cell.getContent(k);
        if (hasExpression(tableHandle,item,keyExpression,columnBindingExpression)) {
          cell.setDisplayGroupIcon(true);
          return;
        }
      }
      if (cell.getContentCount() > 0 && null == firstStuffedCell) {
        firstStuffedCell=cell;
      }
    }
  }
  if (null != firstStuffedCell) {
    firstStuffedCell.setDisplayGroupIcon(true);
  }
 else {
    RowDesign row=(RowDesign)groupHeader.getContent(0);
    if (null != row) {
      CellDesign cell=row.getCell(0);
      if (null != cell) {
        cell.setDisplayGroupIcon(true);
      }
    }
  }
}