nus-yam/ex-repair huggingface dataset:
Program: 70454
Project: 70454
Buggy source:
/** 
 * Gets the absolute path for the given <code>base</code> and <code> relativePath</code> . <p> The <code>base</code> value should be directory ONLY and does NOT contain file name and the format can be: <ul> <li>./../hello/ <li>C:\\hello\..\ <li>/C:/../hello/ </ul> The spearator in the return path is platform-depedent.
 * @param base the base directory
 * @param relativePath the relative path
 * @return the absolute path
 */
private static String resolveAbsolutePathFromString(String base,String relativePath){
  if (base == null || relativePath == null)   return relativePath;
  try {
    URI uri=new URI(relativePath);
    if (uri.isAbsolute())     return relativePath;
  }
 catch (  URISyntaxException e) {
  }
  boolean appendDirectorySeparator=false;
  if (base.length() > 0 && relativePath.length() > 0) {
    char lastBaseChar=base.charAt(base.length() - 1);
    char firstRelativeChar=relativePath.charAt(0);
    if (lastBaseChar != '/' && lastBaseChar != File.separatorChar && firstRelativeChar != '/' && firstRelativeChar != File.separatorChar)     appendDirectorySeparator=true;
  }
  if (appendDirectorySeparator)   return base + '/' + relativePath;
  return base + relativePath;
}

Fixed version (ground truth):
/** 
 * Gets the absolute path for the given <code>base</code> and <code> relativePath</code> . <p> The <code>base</code> value should be directory ONLY and does NOT contain file name and the format can be: <ul> <li>./../hello/ <li>C:\\hello\..\ <li>/C:/../hello/ </ul> The spearator in the return path is platform-depedent.
 * @param base the base directory
 * @param relativePath the relative path
 * @return the absolute path
 */
private static String resolveAbsolutePathFromString(String base,String relativePath){
  if (base == null || relativePath == null)   return relativePath;
  URI uri=URIUtilImpl.resolveAbsolutePath(relativePath);
  if (uri != null && uri.isAbsolute()) {
    return relativePath;
  }
  boolean appendDirectorySeparator=false;
  if (base.length() > 0 && relativePath.length() > 0) {
    char lastBaseChar=base.charAt(base.length() - 1);
    char firstRelativeChar=relativePath.charAt(0);
    if (lastBaseChar != '/' && lastBaseChar != File.separatorChar && firstRelativeChar != '/' && firstRelativeChar != File.separatorChar)     appendDirectorySeparator=true;
  }
  String path=null;
  if (appendDirectorySeparator) {
    path=base + '/' + relativePath;
  }
 else {
    path=base + relativePath;
  }
  uri=URIUtilImpl.resolveAbsolutePath(path);
  if (uri != null) {
    return uri.normalize().toString();
  }
  return path;
}
Program: 70455
Project: 70455
Buggy source:
public TextAreaLayout(ContainerArea parent,LayoutContext context,IContent content){
  parentLM=(InlineStackingArea)parent;
  ITextContent textContent=(ITextContent)content;
  String text=textContent.getText();
  if (text != null && text.length() != 0) {
    transform(textContent);
    this.textContent=textContent;
    comp=new TextCompositor(textContent,context.getFontManager(),context);
    ContainerArea ancestor=parentLM;
    do {
      if (null == ancestor) {
        comp.setNewLineStatus(true);
        return;
      }
      if (!ancestor.isEmpty()) {
        comp.setNewLineStatus(false);
        return;
      }
      if (ancestor instanceof LineArea) {
        comp.setNewLineStatus(ancestor.isEmpty());
        return;
      }
      ancestor=ancestor.getParent();
    }
 while (true);
  }
}

Fixed version (ground truth):
public TextAreaLayout(ContainerArea parent,LayoutContext context,IContent content){
  parentLM=(InlineStackingArea)parent;
  ITextContent textContent=(ITextContent)content;
  String text=textContent.getText();
  if (text != null) {
    if (text.length() == 0)     textContent.setText("String_Node_Str");
 else     transform(textContent);
  }
  this.textContent=textContent;
  comp=new TextCompositor(textContent,context.getFontManager(),context);
  ContainerArea ancestor=parentLM;
  do {
    if (null == ancestor) {
      comp.setNewLineStatus(true);
      return;
    }
    if (!ancestor.isEmpty()) {
      comp.setNewLineStatus(false);
      return;
    }
    if (ancestor instanceof LineArea) {
      comp.setNewLineStatus(ancestor.isEmpty());
      return;
    }
    ancestor=ancestor.getParent();
  }
 while (true);
}
Program: 70458
Project: 70458
Buggy source:
public void update(AbstractArea area) throws BirtException {
  area.setAllocatedPosition(currentIP,currentBP);
  currentIP+=area.getAllocatedWidth();
  if (currentIP > width) {
    setWidth(currentIP);
  }
  int height=area.getAllocatedHeight();
  if (height > getHeight()) {
    this.height=height;
  }
}

Fixed version (ground truth):
public void update(AbstractArea area) throws BirtException {
  int aWidth=area.getAllocatedWidth();
  if (aWidth + currentIP > maxAvaWidth) {
    removeChild(area);
    endLine();
    children.add(area);
  }
  area.setAllocatedPosition(currentIP,currentBP);
  currentIP+=aWidth;
  if (currentIP > maxAvaWidth) {
    setWidth(currentIP);
  }
  int height=area.getAllocatedHeight();
  if (height > getHeight()) {
    this.height=height;
  }
}
Program: 70462
Project: 70462
Buggy source:
/** 
 * Reusable 'strokes' for rendering lines may be obtained from here
 * @param ls
 * @return
 */
public final Stroke getCachedStroke(LineAttributes lia){
  if (lia == null)   return null;
  Stroke s=_htLineStyles.get(lia);
  if (s == null) {
    BasicStroke bs=null;
    if (lia.getStyle().getValue() == LineStyle.DASHED) {
      float[] faStyle=new float[]{6.0f,4.0f};
      bs=new BasicStroke(lia.getThickness(),BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND,0,faStyle,0);
    }
 else     if (lia.getStyle().getValue() == LineStyle.DOTTED) {
      float[] faStyle=new float[]{1.0f,4.0f};
      bs=new BasicStroke(lia.getThickness(),BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND,0,faStyle,0);
    }
 else     if (lia.getStyle().getValue() == LineStyle.DASH_DOTTED) {
      float[] faStyle=new float[]{6.0f,4.0f,1.0f,4.0f};
      bs=new BasicStroke(lia.getThickness(),BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND,0,faStyle,0);
    }
 else     if (lia.getStyle().getValue() == LineStyle.SOLID) {
      bs=new BasicStroke(lia.getThickness(),BasicStroke.CAP_SQUARE,BasicStroke.JOIN_MITER);
    }
    if (bs != null) {
      _htLineStyles.put(lia,bs);
    }
    return bs;
  }
  return s;
}

Fixed version (ground truth):
/** 
 * Reusable 'strokes' for rendering lines may be obtained from here
 * @param ls
 * @return
 */
public final Stroke getCachedStroke(LineAttributes lia){
  if (lia == null)   return null;
  Stroke s=_htLineStyles.get(lia);
  if (s == null) {
    BasicStroke bs=null;
    if (lia.getStyle().getValue() == LineStyle.DASHED) {
      float[] faStyle=new float[]{6.0f,4.0f};
      bs=new BasicStroke(lia.getThickness(),BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND,0,faStyle,0);
    }
 else     if (lia.getStyle().getValue() == LineStyle.DOTTED) {
      float[] faStyle=new float[]{1.0f,4.0f};
      bs=new BasicStroke(lia.getThickness(),BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND,0,faStyle,0);
    }
 else     if (lia.getStyle().getValue() == LineStyle.DASH_DOTTED) {
      float[] faStyle=new float[]{6.0f,4.0f,1.0f,4.0f};
      bs=new BasicStroke(lia.getThickness(),BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND,0,faStyle,0);
    }
 else     if (lia.getStyle().getValue() == LineStyle.SOLID) {
      bs=new BasicStroke(lia.getThickness(),BasicStroke.CAP_SQUARE,BasicStroke.JOIN_ROUND);
    }
    if (bs != null) {
      _htLineStyles.put(lia,bs);
    }
    return bs;
  }
  return s;
}
Program: 70463
Project: 70463
Buggy source:
public boolean handleDescribe(IDataSetInstanceHandle dataSet,IScriptDataSetMetaDataDefinition metaData) throws BirtException {
  try {
    if (!this.useDescribeEventHandler) {
      JSScriptStatus status=handleJS(dataSet.getScriptScope(),dataSet.getName(),DESCRIBE,((ScriptDataSetHandle)dataSetHandle).getDescribe());
      if (status.didRun()) {
        Object result=status.result();
        if (result instanceof Boolean)         return ((Boolean)result).booleanValue();
 else         throw new DataException(ResourceConstants.EXPECT_BOOLEAN_RETURN_TYPE,"String_Node_Str");
      }
    }
    if (scriptedEventHandler != null)     return scriptedEventHandler.describe(new DataSetInstance(dataSet),new ScriptedDataSetMetaData(metaData));
  }
 catch (  Exception e) {
    addException(context,e);
  }
  return false;
}

Fixed version (ground truth):
public boolean handleDescribe(IDataSetInstanceHandle dataSet,IScriptDataSetMetaDataDefinition metaData) throws BirtException {
  try {
    if (!this.useDescribeEventHandler) {
      JSScriptStatus status=handleJS(getScriptScope(dataSet),dataSet.getName(),DESCRIBE,((ScriptDataSetHandle)dataSetHandle).getDescribe());
      if (status.didRun()) {
        Object result=status.result();
        if (result instanceof Boolean)         return ((Boolean)result).booleanValue();
 else         throw new DataException(ResourceConstants.EXPECT_BOOLEAN_RETURN_TYPE,"String_Node_Str");
      }
    }
    if (scriptedEventHandler != null)     return scriptedEventHandler.describe(new DataSetInstance(dataSet),new ScriptedDataSetMetaData(metaData));
  }
 catch (  Exception e) {
    addException(context,e);
  }
  return false;
}
Program: 70464
Project: 70464
Buggy source:
public void handleOpen(IDataSetInstanceHandle dataSet) throws BirtException {
  try {
    if (!this.useOpenEventHandler) {
      JSScriptStatus status=handleJS(dataSet.getScriptScope(),dataSet.getName(),OPEN,((ScriptDataSetHandle)dataSetHandle).getOpen());
      if (status.didRun())       return;
    }
    if (scriptedEventHandler != null)     scriptedEventHandler.open(new DataSetInstance(dataSet));
  }
 catch (  Exception e) {
    addException(context,e);
  }
}

Fixed version (ground truth):
public void handleOpen(IDataSetInstanceHandle dataSet) throws BirtException {
  try {
    if (!this.useOpenEventHandler) {
      JSScriptStatus status=handleJS(getScriptScope(dataSet),dataSet.getName(),OPEN,((ScriptDataSetHandle)dataSetHandle).getOpen());
      if (status.didRun())       return;
    }
    if (scriptedEventHandler != null)     scriptedEventHandler.open(new DataSetInstance(dataSet));
  }
 catch (  Exception e) {
    addException(context,e);
  }
}
Program: 70465
Project: 70465
Buggy source:
public void handleClose(IDataSetInstanceHandle dataSet){
  try {
    if (!this.useCloseEventHandler) {
      JSScriptStatus status=handleJS(dataSet.getScriptScope(),dataSet.getName(),CLOSE,((ScriptDataSetHandle)dataSetHandle).getClose());
      if (status.didRun())       return;
    }
    if (scriptedEventHandler != null)     scriptedEventHandler.close(new DataSetInstance(dataSet));
  }
 catch (  Exception e) {
    addException(context,e);
  }
}

Fixed version (ground truth):
public void handleClose(IDataSetInstanceHandle dataSet){
  try {
    if (!this.useCloseEventHandler) {
      JSScriptStatus status=handleJS(getScriptScope(dataSet),dataSet.getName(),CLOSE,((ScriptDataSetHandle)dataSetHandle).getClose());
      if (status.didRun())       return;
    }
    if (scriptedEventHandler != null)     scriptedEventHandler.close(new DataSetInstance(dataSet));
  }
 catch (  Exception e) {
    addException(context,e);
  }
}
Program: 70466
Project: 70466
Buggy source:
public boolean handleFetch(IDataSetInstanceHandle dataSet,IDataRow row){
  try {
    if (!useFetchEventHandler) {
      JSScriptStatus status=handleJS(dataSet.getScriptScope(),dataSet.getName(),FETCH,((ScriptDataSetHandle)dataSetHandle).getFetch());
      if (status.didRun()) {
        Object result=status.result();
        if (result instanceof Boolean)         return ((Boolean)result).booleanValue();
 else         throw new DataException(ResourceConstants.EXPECT_BOOLEAN_RETURN_TYPE,"String_Node_Str");
      }
    }
    if (scriptedEventHandler != null)     return scriptedEventHandler.fetch(new DataSetInstance(dataSet),new UpdatableDataSetRow(row));
  }
 catch (  Exception e) {
    addException(context,e);
  }
  return false;
}

Fixed version (ground truth):
public boolean handleFetch(IDataSetInstanceHandle dataSet,IDataRow row){
  try {
    if (!useFetchEventHandler) {
      JSScriptStatus status=handleJS(getScriptScope(dataSet),dataSet.getName(),FETCH,((ScriptDataSetHandle)dataSetHandle).getFetch());
      if (status.didRun()) {
        Object result=status.result();
        if (result instanceof Boolean)         return ((Boolean)result).booleanValue();
 else         throw new DataException(ResourceConstants.EXPECT_BOOLEAN_RETURN_TYPE,"String_Node_Str");
      }
    }
    if (scriptedEventHandler != null)     return scriptedEventHandler.fetch(new DataSetInstance(dataSet),new UpdatableDataSetRow(row));
  }
 catch (  Exception e) {
    addException(context,e);
  }
  return false;
}
Program: 70467
Project: 70467
Buggy source:
public SheetData[] next(){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  SheetData[] rowDatas=new SheetData[columnIndexes.length];
  for (int i=0; i < columnIndexes.length; i++) {
    ArrayList<SheetData> columnData=columns.get(i);
    int cursor=columnIndexes[i];
    int size=columnData.size();
    for (int j=cursor; j < size; j++) {
      SheetData data=columnData.get(j);
      int dataRowIndex=data.getRowIndex();
      if (dataRowIndex == rowIndex) {
        rowDatas[i]=data;
        columnIndexes[i]=j + 1;
        break;
      }
 else       if (dataRowIndex > rowIndex) {
        columnIndexes[i]=j;
        break;
      }
    }
  }
  rowIndex++;
  return rowDatas;
}

Fixed version (ground truth):
public SheetData[] next(){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  SheetData[] rowDatas=new SheetData[columnIndexes.length];
  for (int i=0; i < columnIndexes.length; i++) {
    ArrayList<SheetData> columnData=columns.get(i);
    int cursor=columnIndexes[i];
    int size=columnData.size();
    for (int j=cursor; j < size; j++) {
      SheetData data=columnData.get(j);
      int dataRowIndex=data.getRowIndex();
      if (dataRowIndex == rowIndex) {
        rowDatas[i]=data;
        if (!rowIndex2Height.isEmpty() && rowIndex2Height.containsKey(rowIndex))         rowDatas[i].setRowHeight(rowIndex2Height.get(rowIndex));
        columnIndexes[i]=j + 1;
        break;
      }
 else       if (dataRowIndex > rowIndex) {
        columnIndexes[i]=j;
        break;
      }
    }
  }
  rowIndex++;
  return rowDatas;
}
Program: 70468
Project: 70468
Buggy source:
public void endRow(IRowContent row){
  engine.endRow();
}

Fixed version (ground truth):
public void endRow(IRowContent row){
  engine.endRow(row.getHeight());
}
Program: 70469
Project: 70469
Buggy source:
public void startRow(double rowHeight){
  writer.openTag("String_Node_Str");
}

Fixed version (ground truth):
public void startRow(double rowHeight){
  writer.openTag("String_Node_Str");
  writer.attribute("String_Node_Str",0);
  writer.attribute("String_Node_Str",rowHeight);
}
Program: 70471
Project: 70471
Buggy source:
public RowData next(){
  SheetData[] row=rowIterator.next();
  List<SheetData> data=new ArrayList<SheetData>();
  int width=Math.min(row.length,maxCol - 1);
  double rowHeight=DEFAULT_ROW_HEIGHT;
  for (int i=0; i < width; i++) {
    SheetData d=row[i];
    if (d == null || d.isBlank()) {
      continue;
    }
    if (d.isProcessed()) {
      continue;
    }
    d.setProcessed(true);
    data.add(row[i]);
    if (d instanceof ImageData) {
      ImageData imagedata=(ImageData)d;
      double height=imagedata.getHeight();
      if (height > rowHeight)       rowHeight=height;
    }
  }
  SheetData[] rowdata=new SheetData[data.size()];
  data.toArray(rowdata);
  return new RowData(rowdata,rowHeight);
}

Fixed version (ground truth):
public RowData next(){
  SheetData[] row=rowIterator.next();
  List<SheetData> data=new ArrayList<SheetData>();
  int width=Math.min(row.length,maxCol - 1);
  double rowHeight=DEFAULT_ROW_HEIGHT;
  for (int i=0; i < width; i++) {
    SheetData d=row[i];
    if (d == null || d.isBlank()) {
      continue;
    }
    if (d.isProcessed()) {
      continue;
    }
    d.setProcessed(true);
    data.add(row[i]);
    if (d instanceof ImageData) {
      ImageData imagedata=(ImageData)d;
      double height=imagedata.getHeight();
      if (height > rowHeight)       rowHeight=height;
    }
 else {
      double height=d.getRowHeight();
      rowHeight=height > rowHeight ? height : rowHeight;
    }
  }
  SheetData[] rowdata=new SheetData[data.size()];
  data.toArray(rowdata);
  return new RowData(rowdata,rowHeight);
}
Program: 70472
Project: 70472
Buggy source:
public void endRow(){
  synchronize();
  endContainer();
}

Fixed version (ground truth):
public void endRow(DimensionType rowHeight){
  synchronize(rowHeight);
  endContainer();
}
Program: 70474
Project: 70474
Buggy source:
public void align(boolean lastLine,LayoutContext context){
  assert(parent instanceof BlockContainerArea);
  CSSValue align=((BlockContainerArea)parent).getTextAlign();
  boolean isRightAligned=BidiAlignmentResolver.isRightAligned(parent.content,align,lastLine);
  if ((isRightAligned || IStyle.CENTER_VALUE.equals(align))) {
    int spacing=width - currentIP;
    Iterator iter=getChildren();
    while (iter.hasNext()) {
      AbstractArea area=(AbstractArea)iter.next();
      if (spacing > 0) {
        if (isRightAligned) {
          if (parent.content.isDirectionRTL()) {
            area.setPosition(spacing + area.getX(),area.getY());
          }
 else {
            area.setPosition(spacing + area.getX() + ignoreRightMostWhiteSpace(),area.getY());
          }
        }
 else         if (IStyle.CENTER_VALUE.equals(align)) {
          area.setPosition(spacing / 2 + area.getX(),area.getY());
        }
      }
    }
  }
 else   if (IStyle.JUSTIFY_VALUE.equals(align) && !lastLine) {
    justify();
  }
  if (context.getBidiProcessing())   reorderVisually();
  verticalAlign();
}

Fixed version (ground truth):
public void align(boolean lastLine,LayoutContext context){
  assert(parent instanceof BlockContainerArea);
  CSSValue align=((BlockContainerArea)parent).getTextAlign();
  boolean isRightAligned=BidiAlignmentResolver.isRightAligned(parent.content,align,lastLine);
  if ((isRightAligned || IStyle.CENTER_VALUE.equals(align))) {
    int spacing=width - currentIP;
    Iterator iter=getChildren();
    while (iter.hasNext()) {
      AbstractArea area=(AbstractArea)iter.next();
      if (isRightAligned) {
        if (parent.content.isDirectionRTL()) {
          area.setPosition(spacing + area.getX(),area.getY());
        }
 else {
          area.setPosition(spacing + area.getX() + ignoreRightMostWhiteSpace(),area.getY());
        }
      }
 else       if (IStyle.CENTER_VALUE.equals(align)) {
        area.setPosition(spacing / 2 + area.getX(),area.getY());
      }
    }
  }
 else   if (IStyle.JUSTIFY_VALUE.equals(align) && !lastLine) {
    justify();
  }
  if (context.getBidiProcessing())   reorderVisually();
  verticalAlign();
}
Program: 70475
Project: 70475
Buggy source:
public void run(){
  try {
    this.statement.execute();
    if (this.closeStatementAfterExecution)     this.statement.close();
  }
 catch (  Exception e) {
    this.exception=new DataException(e.getLocalizedMessage());
  }
}

Fixed version (ground truth):
public void run(){
  try {
    while (!threadQuiter.isStopped()) {
      if (stopSign.isStopped()) {
        this.statement.cancel();
        threadQuiter.stop();
      }
    }
  }
 catch (  Exception e) {
    this.exception=new DataException(e.getLocalizedMessage());
  }
}
Program: 70478
Project: 70478
Buggy source:
public void layout() throws BirtException {
  init();
  if (PropertyUtil.isInlineElement(image)) {
    assert(parent instanceof InlineStackingArea);
    InlineStackingArea lineParent=(InlineStackingArea)parent;
    if (root.getAllocatedWidth() > parent.getCurrentMaxContentWidth()) {
      if (!lineParent.isEmptyLine()) {
        lineParent.endLine();
        layout();
      }
 else {
        parent.add(root);
        parent.update(root);
        return;
      }
    }
 else {
      parent.add(root);
      parent.update(root);
      return;
    }
  }
 else {
    parent.add(root);
    if (!parent.isInInlineStacking && context.isAutoPageBreak()) {
      int aHeight=root.getAllocatedHeight();
      if (aHeight + parent.getAbsoluteBP() > context.getMaxBP()) {
        parent.autoPageBreak();
      }
    }
    parent.update(root);
  }
}

Fixed version (ground truth):
public void layout() throws BirtException {
  init();
  if (PropertyUtil.isInlineElement(image)) {
    assert(parent instanceof InlineStackingArea);
    InlineStackingArea lineParent=(InlineStackingArea)parent;
    if (root.getAllocatedWidth() > parent.getCurrentMaxContentWidth()) {
      if (!lineParent.isEmptyLine()) {
        lineParent.endLine();
        layout();
      }
 else {
        parent.add(root);
        root.finished=true;
        parent.update(root);
        return;
      }
    }
 else {
      parent.add(root);
      root.finished=true;
      parent.update(root);
      return;
    }
  }
 else {
    parent.add(root);
    if (!parent.isInInlineStacking && context.isAutoPageBreak()) {
      int aHeight=root.getAllocatedHeight();
      if (aHeight + parent.getAbsoluteBP() > context.getMaxBP()) {
        parent.autoPageBreak();
      }
    }
    root.finished=true;
    parent.update(root);
  }
}
Program: 70479
Project: 70479
Buggy source:
/** 
 * Convert IGroupDefn to IQuery.GroupSpec
 * @param cx
 * @param src
 * @return
 * @throws DataException
 */
static IQuery.GroupSpec groupDefnToSpec(Context cx,IGroupDefinition src,String expr,String columnName,int index,boolean doSortBeforeGrouping) throws DataException {
  ColumnInfo groupKeyInfo=new ColumnInfo(index,columnName);
  int groupIndex=groupKeyInfo.getColumnIndex();
  String groupKey=groupKeyInfo.getColumnName();
  boolean isComplexExpression=true;
  IQuery.GroupSpec dest=new IQuery.GroupSpec(groupIndex,groupKey);
  dest.setName(src.getName());
  dest.setInterval(src.getInterval());
  dest.setIntervalRange(src.getIntervalRange());
  dest.setIntervalStart(src.getIntervalStart());
  dest.setSortDirection(doSortBeforeGrouping ? src.getSortDirection() : IQuery.NO_SORT_BEFORE_GROUPING);
  dest.setFilters(src.getFilters());
  if (src.getSorts().size() != 0) {
    dest.setSorts(src.getSorts());
  }
  dest.setIsComplexExpression(isComplexExpression);
  return dest;
}

Fixed version (ground truth):
/** 
 * Convert IGroupDefn to IQuery.GroupSpec
 * @param cx
 * @param src
 * @return
 * @throws DataException
 */
static IQuery.GroupSpec groupDefnToSpec(Context cx,IGroupDefinition src,String expr,String columnName,int index,int dataType,boolean doSortBeforeGrouping) throws DataException {
  ColumnInfo groupKeyInfo=new ColumnInfo(index,columnName);
  int groupIndex=groupKeyInfo.getColumnIndex();
  String groupKey=groupKeyInfo.getColumnName();
  boolean isComplexExpression=true;
  IQuery.GroupSpec dest=new IQuery.GroupSpec(groupIndex,groupKey);
  dest.setName(src.getName());
  dest.setInterval(src.getInterval());
  dest.setIntervalRange(src.getIntervalRange());
  dest.setIntervalStart(src.getIntervalStart());
  dest.setSortDirection(doSortBeforeGrouping ? src.getSortDirection() : IQuery.NO_SORT_BEFORE_GROUPING);
  dest.setDataType(dataType);
  dest.setFilters(src.getFilters());
  if (src.getSorts().size() != 0) {
    dest.setSorts(src.getSorts());
  }
  dest.setIsComplexExpression(isComplexExpression);
  return dest;
}
Program: 70480
Project: 70480
Buggy source:
/** 
 * 1) Creates row wrapper. 2) For the null cell in the row wrapper, fills the relevant position with dummy cell or empty cell. 3) Updates the height of the row and the cells in the row.
 * @param rowArea current rowArea.
 */
private void updateRow(RowArea rowArea,boolean isFixedLayout){
  RowArea lastRow=(RowArea)rows.getCurrent();
  int height=rowArea.getSpecifiedHeight();
  if (!isFixedLayout) {
    for (int i=startCol; i <= endCol; i++) {
      CellArea upperCell=null;
      if (lastRow != null) {
        upperCell=lastRow.getCell(i);
      }
      if (upperCell != null && (upperCell.getRowSpan() > 1)) {
        DummyCell dummyCell=createDummyCell(upperCell);
        rowArea.setCell(dummyCell);
        int delta=dummyCell.getDelta();
        if (dummyCell.getRowSpan() == 1) {
          height=Math.max(height,dummyCell.getCell().getHeight() - delta);
        }
        i=i + upperCell.getColSpan() - 1;
      }
 else {
        CellArea cell=rowArea.getCell(i);
        if (cell != null && cell.getRowSpan() == 1) {
          height=Math.max(height,cell.getHeight());
          i=i + cell.getColSpan() - 1;
        }
      }
    }
  }
  updateRowHeight(rowArea,height,isFixedLayout);
}

Fixed version (ground truth):
/** 
 * 1) Creates row wrapper. 2) For the null cell in the row wrapper, fills the relevant position with dummy cell or empty cell. 3) Updates the height of the row and the cells in the row.
 * @param rowArea current rowArea.
 */
private void updateRow(RowArea rowArea,boolean isFixedLayout){
  RowArea lastRow=(RowArea)rows.getCurrent();
  int height=rowArea.getSpecifiedHeight();
  if (!isFixedLayout || height == 0) {
    for (int i=startCol; i <= endCol; i++) {
      CellArea upperCell=null;
      if (lastRow != null) {
        upperCell=lastRow.getCell(i);
      }
      if (upperCell != null && (upperCell.getRowSpan() > 1)) {
        DummyCell dummyCell=createDummyCell(upperCell);
        rowArea.setCell(dummyCell);
        int delta=dummyCell.getDelta();
        if (dummyCell.getRowSpan() == 1) {
          height=Math.max(height,dummyCell.getCell().getHeight() - delta);
        }
        i=i + upperCell.getColSpan() - 1;
      }
 else {
        CellArea cell=rowArea.getCell(i);
        if (cell != null && cell.getRowSpan() == 1) {
          height=Math.max(height,cell.getHeight());
          i=i + cell.getColSpan() - 1;
        }
      }
    }
  }
  updateRowHeight(rowArea,height,isFixedLayout);
}
Program: 70482
Project: 70482
Buggy source:
/** 
 * Handles all global actions
 */
private void handleGlobalAction(){
  for (int i=0; i < GlobalActionFactory.GLOBAL_SELECTION_ACTIONS.length; i++) {
    String id=GlobalActionFactory.GLOBAL_SELECTION_ACTIONS[i];
    getSite().getActionBars().setGlobalActionHandler(id,GlobalActionFactory.createSelectionAction(id,this));
  }
  for (int i=0; i < GlobalActionFactory.GLOBAL_DATA_ACTIONS.length; i++) {
    String id=GlobalActionFactory.GLOBAL_DATA_ACTIONS[i];
    getSite().getActionBars().setGlobalActionHandler(id,GlobalActionFactory.createSelectionAction(id,this));
  }
  for (int i=0; i < GlobalActionFactory.GLOBAL_PARAMETER_ACTIONS.length; i++) {
    String id=GlobalActionFactory.GLOBAL_PARAMETER_ACTIONS[i];
    getSite().getActionBars().setGlobalActionHandler(id,GlobalActionFactory.createSelectionAction(id,this));
  }
  for (int i=0; i < GlobalActionFactory.GLOBAL_STACK_ACTIONS.length; i++) {
    String id=GlobalActionFactory.GLOBAL_STACK_ACTIONS[i];
    getSite().getActionBars().setGlobalActionHandler(id,GlobalActionFactory.createStackAction(id,getRoot().getCommandStack()));
  }
  getSite().getActionBars().updateActionBars();
}

Fixed version (ground truth):
/** 
 * Handles all global actions
 */
private void handleGlobalAction(){
  for (int i=0; i < GlobalActionFactory.GLOBAL_SELECTION_ACTIONS.length; i++) {
    String id=GlobalActionFactory.GLOBAL_SELECTION_ACTIONS[i];
    getSite().getActionBars().setGlobalActionHandler(id,GlobalActionFactory.createSelectionAction(id,this));
  }
  for (int i=0; i < GlobalActionFactory.GLOBAL_STACK_ACTIONS.length; i++) {
    String id=GlobalActionFactory.GLOBAL_STACK_ACTIONS[i];
    getSite().getActionBars().setGlobalActionHandler(id,GlobalActionFactory.createStackAction(id,getRoot().getCommandStack()));
  }
  getSite().getActionBars().updateActionBars();
}
Program: 70484
Project: 70484
Buggy source:
private Label addDescriptionLabel(Composite parent,int horizontalSpan,String description){
  Label label=new Label(parent,SWT.WRAP);
{
    GridData gd=new GridData();
    gd.widthHint=200;
    gd.horizontalSpan=horizontalSpan;
    label.setLayoutData(gd);
    label.setText(description);
  }
  return label;
}

Fixed version (ground truth):
private Label addDescriptionLabel(Composite parent,int horizontalSpan,String description){
  Label label=new Label(parent,SWT.WRAP);
{
    GridData gd=new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint=200;
    gd.horizontalSpan=horizontalSpan;
    label.setLayoutData(gd);
    label.setText(description);
  }
  return label;
}
Program: 70487
Project: 70487
Buggy source:
public void initialize() throws BirtException {
  IStyle style=content.getStyle();
  if (style == null || style.isEmpty()) {
    hasStyle=false;
    boxStyle=BoxStyle.DEFAULT;
    localProperties=LocalProperties.DEFAULT;
  }
 else {
    buildProperties(content,context);
  }
}

Fixed version (ground truth):
public void initialize() throws BirtException {
  IStyle style=content.getStyle();
  if (style == null || style.isEmpty()) {
    hasStyle=false;
    boxStyle=BoxStyle.DEFAULT;
    localProperties=LocalProperties.DEFAULT;
    action=content.getHyperlinkAction();
    bookmark=content.getBookmark();
  }
 else {
    buildProperties(content,context);
  }
}
Program: 70488
Project: 70488
Buggy source:
public void initialize() throws BirtException {
  IStyle style=content.getStyle();
  if (style == null || style.isEmpty()) {
    hasStyle=false;
    boxStyle=BoxStyle.DEFAULT;
    localProperties=LocalProperties.DEFAULT;
  }
 else {
    buildProperties(content,context);
  }
}

Fixed version (ground truth):
public void initialize() throws BirtException {
  IStyle style=content.getStyle();
  if (style == null || style.isEmpty()) {
    hasStyle=false;
    boxStyle=BoxStyle.DEFAULT;
    localProperties=LocalProperties.DEFAULT;
    action=content.getHyperlinkAction();
    bookmark=content.getBookmark();
  }
 else {
    buildProperties(content,context);
  }
}
Program: 70489
Project: 70489
Buggy source:
protected void updatePageDimension(PageArea page){
  if (page != null && page.getRoot().getChildrenCount() > 0) {
    int maxWidth=context.getMaxWidth();
    int maxHeight=context.getMaxHeight();
    int prefWidth=context.getPreferenceWidth();
    int prefHeight=currentBP;
    Iterator iter=page.getBody().getChildren();
    while (iter.hasNext()) {
      AbstractArea area=(AbstractArea)iter.next();
      prefWidth=Math.max(prefWidth,area.getAllocatedX() + area.getAllocatedWidth());
    }
    if (prefHeight > maxHeight) {
      ((ContainerArea)page.getBody()).setHeight(prefHeight);
      floatingFooter(page);
      int deltaHeight=prefHeight - maxHeight;
      ContainerArea pageRoot=(ContainerArea)page.getRoot();
      pageRoot.setHeight(pageRoot.getHeight() + deltaHeight);
      page.setHeight(pageContentHeight + deltaHeight);
    }
    if (prefWidth > maxWidth) {
      ((ContainerArea)page.getBody()).setWidth(prefWidth);
      int deltaWidth=prefWidth - maxWidth;
      ContainerArea pageRoot=(ContainerArea)page.getRoot();
      pageRoot.setWidth(pageRoot.getWidth() + deltaWidth);
      page.setWidth(pageContentWidth + deltaWidth);
    }
  }
}

Fixed version (ground truth):
protected void updatePageDimension(PageArea page){
  if (page != null && page.getRoot().getChildrenCount() > 0) {
    int maxWidth=context.getMaxWidth();
    int maxHeight=context.getMaxHeight();
    int prefWidth=context.getPreferenceWidth();
    int prefHeight=page.getBody().getHeight();
    Iterator iter=page.getBody().getChildren();
    while (iter.hasNext()) {
      AbstractArea area=(AbstractArea)iter.next();
      prefWidth=Math.max(prefWidth,area.getAllocatedX() + area.getAllocatedWidth());
    }
    if (prefHeight > maxHeight) {
      ((ContainerArea)page.getBody()).setHeight(prefHeight);
      floatingFooter(page);
      int deltaHeight=prefHeight - maxHeight;
      ContainerArea pageRoot=(ContainerArea)page.getRoot();
      pageRoot.setHeight(pageRoot.getHeight() + deltaHeight);
      page.setHeight(pageContentHeight + deltaHeight);
    }
    if (prefWidth > maxWidth) {
      ((ContainerArea)page.getBody()).setWidth(prefWidth);
      int deltaWidth=prefWidth - maxWidth;
      ContainerArea pageRoot=(ContainerArea)page.getRoot();
      pageRoot.setWidth(pageRoot.getWidth() + deltaWidth);
      page.setWidth(pageContentWidth + deltaWidth);
    }
  }
}
Program: 70491
Project: 70491
Buggy source:
protected void update() throws BirtException {
  if (parent != null) {
    if (context.isFixedLayout() && height > specifiedHeight) {
      setHeight(specifiedHeight);
      setNeedClip(true);
    }
    if (!isInInlineStacking && context.isAutoPageBreak()) {
      int aHeight=getAllocatedHeight();
      int size=children.size();
      if ((aHeight + parent.getAbsoluteBP() > context.getMaxBP()) && (size > 1)) {
        IStyle style=content.getComputedStyle();
        int widow=Math.min(size,PropertyUtil.getIntValue(style.getProperty(IStyle.STYLE_WIDOWS)));
        int orphan=Math.min(size,PropertyUtil.getIntValue(style.getProperty(IStyle.STYLE_ORPHANS)));
        for (int i=0; i < size; i++) {
          TextLineArea line=(TextLineArea)children.get(i);
          if (i > 0 && i < orphan) {
            line.setPageBreakBefore(IStyle.AVOID_VALUE);
          }
 else           if (i > size - widow) {
            line.setPageBreakBefore(IStyle.AVOID_VALUE);
          }
        }
      }
      while (aHeight + parent.getAbsoluteBP() >= context.getMaxBP()) {
        parent.autoPageBreak();
        aHeight=getAllocatedHeight();
      }
    }
    parent.update(this);
  }
}

Fixed version (ground truth):
protected void update() throws BirtException {
  if (parent != null) {
    if (context.isFixedLayout() && height > specifiedHeight && specifiedHeight > 0) {
      setHeight(specifiedHeight);
      setNeedClip(true);
    }
    if (!isInInlineStacking && context.isAutoPageBreak()) {
      int aHeight=getAllocatedHeight();
      int size=children.size();
      if ((aHeight + parent.getAbsoluteBP() > context.getMaxBP()) && (size > 1)) {
        IStyle style=content.getComputedStyle();
        int widow=Math.min(size,PropertyUtil.getIntValue(style.getProperty(IStyle.STYLE_WIDOWS)));
        int orphan=Math.min(size,PropertyUtil.getIntValue(style.getProperty(IStyle.STYLE_ORPHANS)));
        for (int i=0; i < size; i++) {
          TextLineArea line=(TextLineArea)children.get(i);
          if (i > 0 && i < orphan) {
            line.setPageBreakBefore(IStyle.AVOID_VALUE);
          }
 else           if (i > size - widow) {
            line.setPageBreakBefore(IStyle.AVOID_VALUE);
          }
        }
      }
      while (aHeight + parent.getAbsoluteBP() >= context.getMaxBP()) {
        parent.autoPageBreak();
        aHeight=getAllocatedHeight();
      }
    }
    parent.update(this);
  }
}
Program: 70492
Project: 70492
Buggy source:
public void initialize() throws BirtException {
  createRoot();
  Color backgroundColor=PropertyUtil.getColor(pageContent.getStyle().getProperty(StyleConstants.STYLE_BACKGROUND_COLOR));
  ReportDesignHandle designHandle=pageContent.getReportContent().getDesign().getReportDesign();
  String imageUrl=EmitterUtil.getBackgroundImageUrl(pageContent.getStyle(),designHandle);
  if (backgroundColor != null || imageUrl != null) {
    boxStyle=new BoxStyle();
    boxStyle.setBackgroundColor(backgroundColor);
    if (imageUrl != null) {
      boxStyle.setBackgroundImage(new BackgroundImageInfo(imageUrl));
    }
  }
  context.setMaxHeight(root.getHeight());
  context.setMaxWidth(root.getWidth());
  layoutHeader();
  layoutFooter();
  updateBodySize();
  context.setMaxHeight(body.getHeight());
  context.setMaxWidth(body.getWidth());
  context.setMaxBP(body.getHeight());
  maxAvaWidth=context.getMaxWidth();
}

Fixed version (ground truth):
public void initialize() throws BirtException {
  createRoot();
  Color backgroundColor=PropertyUtil.getColor(pageContent.getStyle().getProperty(StyleConstants.STYLE_BACKGROUND_COLOR));
  ReportDesignHandle designHandle=pageContent.getReportContent().getDesign().getReportDesign();
  String imageUrl=EmitterUtil.getBackgroundImageUrl(pageContent.getStyle(),designHandle);
  if (backgroundColor != null || imageUrl != null) {
    boxStyle=new BoxStyle();
    boxStyle.setBackgroundColor(backgroundColor);
    if (imageUrl != null) {
      boxStyle.setBackgroundImage(new BackgroundImageInfo(imageUrl));
    }
  }
  context.setMaxHeight(root.getHeight());
  context.setMaxWidth(root.getWidth());
  context.setMaxBP(root.getHeight());
  layoutHeader();
  layoutFooter();
  updateBodySize();
  context.setMaxHeight(body.getHeight());
  context.setMaxWidth(body.getWidth());
  context.setMaxBP(body.getHeight());
  maxAvaWidth=context.getMaxWidth();
}
Program: 70493
Project: 70493
Buggy source:
protected void layoutChildren() throws BirtException {
  if (null == textContent)   return;
  while (comp.hasNextArea()) {
    TextArea area=comp.getNextArea(getFreeSpace());
    addTextArea(area);
    comp.setNewLineStatus(false);
    if (area.isLineBreak()) {
      newLine();
      comp.setNewLineStatus(true);
    }
  }
}

Fixed version (ground truth):
protected void layoutChildren() throws BirtException {
  if (null == textContent)   return;
  while (comp.hasNextArea()) {
    TextArea area=comp.getNextArea(getFreeSpace());
    if (area != null) {
      addTextArea(area);
      comp.setNewLineStatus(false);
      if (area.isLineBreak()) {
        newLine();
        comp.setNewLineStatus(true);
      }
    }
  }
}
Program: 70494
Project: 70494
Buggy source:
/** 
 * layout a word, add the word to the line buffer.
 * @param word the word
 */
private void addWordIntoTextArea(TextArea textArea,Word word){
  int textLength=word.getLength();
  int wordWidth=getWordWidth(fontInfo,word);
  wordWidth+=textStyle.getLetterSpacing() * textLength;
  if (textArea.hasSpace(wordWidth)) {
    addWord(textArea,textLength,wordWidth);
    wordVestige=null;
    if (remainWords.hasWord()) {
      if (textArea.hasSpace(textStyle.getWordSpacing())) {
        textArea.addWordSpacing(textStyle.getWordSpacing());
      }
 else {
        textArea.setLineBreak(true);
        hasLineBreak=true;
      }
    }
  }
 else {
    if (isNewLine && textArea.isEmpty()) {
      if (context.isEnableHyphenation()) {
        doHyphenation(word.getValue(),textArea);
      }
 else {
        addWord(textArea,textLength,wordWidth);
      }
    }
 else {
      wordVestige=null;
      remainWord=word;
    }
    textArea.setLineBreak(true);
    hasLineBreak=true;
  }
}

Fixed version (ground truth):
/** 
 * layout a word, add the word to the line buffer.
 * @param word the word
 */
private void addWordIntoTextArea(TextArea textArea,Word word){
  int textLength=word.getLength();
  int wordWidth=getWordWidth(fontInfo,word);
  wordWidth+=textStyle.getLetterSpacing() * textLength;
  if (textArea.hasSpace(wordWidth)) {
    addWord(textArea,textLength,wordWidth);
    wordVestige=null;
    if (remainWords.hasWord()) {
      if (textArea.hasSpace(textStyle.getWordSpacing())) {
        textArea.addWordSpacing(textStyle.getWordSpacing());
      }
 else {
        textArea.setLineBreak(true);
        hasLineBreak=true;
        lineBreakCollapse=LINE_BREAK_COLLAPSE_STANDING_BY;
      }
    }
  }
 else {
    if (isNewLine && textArea.isEmpty()) {
      if (context.isEnableHyphenation()) {
        doHyphenation(word.getValue(),textArea);
      }
 else {
        addWord(textArea,textLength,wordWidth);
      }
    }
 else {
      wordVestige=null;
      remainWord=word;
    }
    textArea.setLineBreak(true);
    hasLineBreak=true;
    lineBreakCollapse=LINE_BREAK_COLLAPSE_STANDING_BY;
  }
}
Program: 70495
Project: 70495
Buggy source:
public TextArea getNextArea(int maxLineWidth){
  if (!hasNextArea()) {
    throw new RuntimeException("String_Node_Str");
  }
  TextArea textArea=getNextTextArea(maxLineWidth);
  offset+=textArea.getTextLength();
  return textArea;
}

Fixed version (ground truth):
public TextArea getNextArea(int maxLineWidth){
  if (!hasNextArea()) {
    throw new RuntimeException("String_Node_Str");
  }
  TextArea textArea=getNextTextArea(maxLineWidth);
  offset+=textArea.getTextLength();
  if (lineBreakCollapse == LINE_BREAK_COLLAPSE_OCCUPY) {
    lineBreakCollapse=LINE_BREAK_COLLAPSE_FREE;
    return null;
  }
  return textArea;
}
Program: 70496
Project: 70496
Buggy source:
private TextArea getNextTextArea(int maxLineWidth){
  if (null != wordVestige) {
    TextArea textArea=createTextArea(textContent,offset,runLevel,fontInfo);
    textArea.setMaxWidth(maxLineWidth);
    textArea.setWidth(0);
    addWordIntoTextArea(textArea,wordVestige);
    return textArea;
  }
  if (null != remainWord) {
    TextArea textArea=createTextArea(textContent,offset,runLevel,fontInfo);
    textArea.setMaxWidth(maxLineWidth);
    textArea.setWidth(0);
    addWordIntoTextArea(textArea,remainWord);
    remainWord=null;
    return textArea;
  }
  if (null == remainWords || !remainWords.hasWord()) {
    Chunk chunk=remainChunks.getNext();
    if (chunk == Chunk.HARD_LINE_BREAK) {
      FontHandler handler=new FontHandler(fontManager,textContent,false);
      TextArea textArea=createTextArea(textContent,handler.getFontInfo(),true);
      textArea.setTextLength(chunk.getLength());
      hasLineBreak=true;
      return textArea;
    }
    fontInfo=chunk.getFontInfo();
    runLevel=chunk.getRunLevel();
    remainWords=new WordRecognizerWrapper(chunk.getText(),context.getLocale());
  }
  TextArea textArea=createTextArea(textContent,offset,runLevel,fontInfo);
  textArea.setMaxWidth(maxLineWidth);
  textArea.setWidth(0);
  addWordsIntoTextArea(textArea,remainWords);
  return textArea;
}

Fixed version (ground truth):
private TextArea getNextTextArea(int maxLineWidth){
  if (null != wordVestige) {
    TextArea textArea=createTextArea(textContent,offset,runLevel,fontInfo);
    textArea.setMaxWidth(maxLineWidth);
    textArea.setWidth(0);
    addWordIntoTextArea(textArea,wordVestige);
    return textArea;
  }
  if (null != remainWord) {
    TextArea textArea=createTextArea(textContent,offset,runLevel,fontInfo);
    textArea.setMaxWidth(maxLineWidth);
    textArea.setWidth(0);
    addWordIntoTextArea(textArea,remainWord);
    remainWord=null;
    return textArea;
  }
  if (null == remainWords || !remainWords.hasWord()) {
    Chunk chunk=remainChunks.getNext();
    if (chunk == Chunk.HARD_LINE_BREAK) {
      FontHandler handler=new FontHandler(fontManager,textContent,false);
      TextArea textArea=createTextArea(textContent,handler.getFontInfo(),true);
      textArea.setTextLength(chunk.getLength());
      hasLineBreak=true;
      if (lineBreakCollapse == LINE_BREAK_COLLAPSE_STANDING_BY) {
        lineBreakCollapse=LINE_BREAK_COLLAPSE_OCCUPY;
      }
      return textArea;
    }
    if (lineBreakCollapse == LINE_BREAK_COLLAPSE_STANDING_BY) {
      lineBreakCollapse=LINE_BREAK_COLLAPSE_FREE;
    }
    fontInfo=chunk.getFontInfo();
    runLevel=chunk.getRunLevel();
    remainWords=new WordRecognizerWrapper(chunk.getText(),context.getLocale());
  }
  TextArea textArea=createTextArea(textContent,offset,runLevel,fontInfo);
  textArea.setMaxWidth(maxLineWidth);
  textArea.setWidth(0);
  addWordsIntoTextArea(textArea,remainWords);
  return textArea;
}
Program: 70497
Project: 70497
Buggy source:
public void layout() throws BirtException {
  initialize();
  LineArea line=new TextLineArea(this,context);
  line.initialize();
  TextAreaLayout text=new TextAreaLayout(line,context,content);
  text.initialize();
  text.layout();
  text.close();
  line.close();
  close();
}

Fixed version (ground truth):
public void layout() throws BirtException {
  initialize();
  TextLineArea line=new TextLineArea(this,context);
  line.initialize();
  line.setTextIndent((ITextContent)content);
  TextAreaLayout text=new TextAreaLayout(line,context,content);
  text.initialize();
  text.layout();
  text.close();
  line.close();
  close();
}
Program: 70498
Project: 70498
Buggy source:
private int adjustWordSpacing(int wordSpacing,ContainerArea area){
  Iterator iter=area.getChildren();
  int delta=0;
  while (iter.hasNext()) {
    AbstractArea child=(AbstractArea)iter.next();
    if (child instanceof TextArea) {
      TextArea textArea=(TextArea)child;
      String text=textArea.getText();
      int blankNumber=text.split("String_Node_Str").length - 1;
      if (blankNumber > 0) {
        TextStyle style=textArea.getStyle();
        int original=style.getWordSpacing();
        style.setWordSpacing(original + wordSpacing);
        int spacing=wordSpacing * blankNumber;
        child.setWidth(child.getWidth() + spacing);
        child.setPosition(child.getX() + delta,child.getY());
        delta+=spacing;
      }
    }
 else     if (child instanceof ContainerArea) {
      child.setPosition(child.getX() + delta,child.getY());
      int spacing=adjustWordSpacing(wordSpacing,(ContainerArea)child);
      child.setWidth(child.getWidth() + spacing);
      delta+=spacing;
    }
 else {
      child.setPosition(child.getX() + delta,child.getY());
    }
  }
  return delta;
}

Fixed version (ground truth):
private int adjustWordSpacing(int wordSpacing,ContainerArea area){
  if (wordSpacing == 0)   return 0;
  Iterator iter=area.getChildren();
  int delta=0;
  while (iter.hasNext()) {
    AbstractArea child=(AbstractArea)iter.next();
    if (child instanceof TextArea) {
      TextArea textArea=(TextArea)child;
      String text=textArea.getText();
      int blankNumber=text.split("String_Node_Str").length - 1;
      if (blankNumber > 0) {
        TextStyle style=new TextStyle(textArea.getStyle());
        int original=style.getWordSpacing();
        style.setWordSpacing(original + wordSpacing);
        textArea.setStyle(style);
        int spacing=wordSpacing * blankNumber;
        child.setWidth(child.getWidth() + spacing);
        child.setPosition(child.getX() + delta,child.getY());
        delta+=spacing;
      }
    }
 else     if (child instanceof ContainerArea) {
      child.setPosition(child.getX() + delta,child.getY());
      int spacing=adjustWordSpacing(wordSpacing,(ContainerArea)child);
      child.setWidth(child.getWidth() + spacing);
      delta+=spacing;
    }
 else {
      child.setPosition(child.getX() + delta,child.getY());
    }
  }
  return delta;
}
Program: 70499
Project: 70499
Buggy source:
protected void update() throws BirtException {
  if (parent != null) {
    if (context.isFixedLayout() && height > specifiedHeight) {
      setHeight(specifiedHeight);
      setNeedClip(true);
    }
    if (!isInInlineStacking && context.isAutoPageBreak()) {
      int aHeight=getAllocatedHeight();
      int size=children.size();
      if ((aHeight + parent.getAbsoluteBP() > context.getMaxBP()) && (size > 1)) {
        IStyle style=content.getComputedStyle();
        int widow=PropertyUtil.getIntValue(style.getProperty(IStyle.STYLE_WIDOWS));
        int orphan=PropertyUtil.getIntValue(style.getProperty(IStyle.STYLE_ORPHANS));
        for (int i=0; i < size; i++) {
          TextLineArea line=(TextLineArea)children.get(i);
          if (i > 0 && i < orphan) {
            line.setPageBreakBefore(IStyle.AVOID_VALUE);
          }
 else           if (i > size - widow) {
            line.setPageBreakBefore(IStyle.AVOID_VALUE);
          }
        }
      }
      while (aHeight + parent.getAbsoluteBP() >= context.getMaxBP()) {
        parent.autoPageBreak();
        aHeight=getAllocatedHeight();
      }
    }
    parent.update(this);
  }
}

Fixed version (ground truth):
protected void update() throws BirtException {
  if (parent != null) {
    if (context.isFixedLayout() && height > specifiedHeight) {
      setHeight(specifiedHeight);
      setNeedClip(true);
    }
    if (!isInInlineStacking && context.isAutoPageBreak()) {
      int aHeight=getAllocatedHeight();
      int size=children.size();
      if ((aHeight + parent.getAbsoluteBP() > context.getMaxBP()) && (size > 1)) {
        IStyle style=content.getComputedStyle();
        int widow=Math.min(size,PropertyUtil.getIntValue(style.getProperty(IStyle.STYLE_WIDOWS)));
        int orphan=Math.min(size,PropertyUtil.getIntValue(style.getProperty(IStyle.STYLE_ORPHANS)));
        for (int i=0; i < size; i++) {
          TextLineArea line=(TextLineArea)children.get(i);
          if (i > 0 && i < orphan) {
            line.setPageBreakBefore(IStyle.AVOID_VALUE);
          }
 else           if (i > size - widow) {
            line.setPageBreakBefore(IStyle.AVOID_VALUE);
          }
        }
      }
      while (aHeight + parent.getAbsoluteBP() >= context.getMaxBP()) {
        parent.autoPageBreak();
        aHeight=getAllocatedHeight();
      }
    }
    parent.update(this);
  }
}