nus-yam/ex-repair huggingface dataset:
Program: 75197
Project: 75197
Buggy source:
/** 
 * @param dirName
 * @param managerName
 * @throws IOException
 * @throws DataException
 */
private void create(String dirName,String managerName) throws IOException, DataException {
  documentObjectMap=new HashMap();
  objectFile=new File(dirName + File.separatorChar + managerName+ "String_Node_Str");
  if (!objectFile.exists()) {
    if (!new File(dirName).exists()) {
      new File(dirName).mkdirs();
    }
    try {
      if (!objectFile.createNewFile()) {
        throw new DataException(ResourceConstants.OLAPFILE_CREATE_FAIL,objectFile.getAbsolutePath());
      }
    }
 catch (    IOException e) {
      throw new DataException(ResourceConstants.OLAPFILE_CREATE_FAIL,e,objectFile.getAbsolutePath());
    }
  }
  objectAccessFile=new BufferedRandomAccessFile(objectFile,"String_Node_Str",1024);
  objectAccessFile.setLength(0);
  oatFile=new File(dirName + File.separatorChar + managerName+ "String_Node_Str");
  if (!oatFile.exists()) {
    if (!oatFile.createNewFile()) {
      throw new DataException(ResourceConstants.OLAPFILE_CREATE_FAIL,oatFile.getAbsolutePath());
    }
  }
  oatAccessFile=new BufferedRandomAccessFile(oatFile,"String_Node_Str",1024);
  oatAccessFile.setLength(0);
  dataFile=new File(dirName + File.separatorChar + managerName+ "String_Node_Str");
  if (!dataFile.exists()) {
    if (!dataFile.createNewFile()) {
      throw new DataException(ResourceConstants.OLAPFILE_CREATE_FAIL,dataFile.getAbsolutePath());
    }
  }
  dataAccessFile=new BufferedRandomAccessFile(dataFile,"String_Node_Str",1024);
  dataAccessFile.setLength(0);
}

Fixed version (ground truth):
/** 
 * @param dirName
 * @param managerName
 * @throws IOException
 * @throws DataException
 */
private void create(String dirName,String managerName) throws IOException, DataException {
  documentObjectMap=new HashMap();
  if (!new File(dirName).exists()) {
    new File(dirName).mkdirs();
  }
  objectFile=new File(dirName + File.separatorChar + managerName+ "String_Node_Str");
  objectAccessFile=new BufferedRandomAccessFile(objectFile,"String_Node_Str",1024,dataFileCacheSize / 5);
  objectAccessFile.setLength(0);
  oatFile=new File(dirName + File.separatorChar + managerName+ "String_Node_Str");
  oatAccessFile=new BufferedRandomAccessFile(oatFile,"String_Node_Str",1024,dataFileCacheSize / 10);
  oatAccessFile.setLength(0);
  dataFile=new File(dirName + File.separatorChar + managerName+ "String_Node_Str");
  dataAccessFile=new BufferedRandomAccessFile(dataFile,"String_Node_Str",1024,dataFileCacheSize);
  dataAccessFile.setLength(0);
}
Program: 75198
Project: 75198
Buggy source:
protected void delegateClose() throws IOException {
  delegate.close();
}

Fixed version (ground truth):
protected void delegateClose() throws IOException {
  if (delegate == null) {
    return;
  }
  delegate.close();
}
Program: 75199
Project: 75199
Buggy source:
protected int delegateRead(byte[] b) throws IOException {
  return delegate.read(b);
}

Fixed version (ground truth):
protected int delegateRead(byte[] b) throws IOException {
  return delegateRead(b,0,b.length);
}
Program: 75200
Project: 75200
Buggy source:
/** 
 * Constructor for the BufferedRandomAccessFile object
 * @param file Description of Parameter
 * @param mode Description of Parameter
 * @param bufferSize Description of Parameter
 * @exception IOException Description of Exception
 */
public BufferedRandomAccessFile(File file,String mode,int bufferSize) throws IOException {
  super(bufferSize);
  delegate=new RandomAccessFile(file,mode);
  fillBuffer();
}

Fixed version (ground truth):
/** 
 * @param file
 * @param mode
 * @param bufferSize
 * @throws IOException
 */
public BufferedRandomAccessFile(File file,String mode,int bufferSize) throws IOException {
  this(file,mode,bufferSize,0);
}
Program: 75201
Project: 75201
Buggy source:
protected void delegateSetLength(long newLength) throws IOException {
  delegate.setLength(newLength);
}

Fixed version (ground truth):
protected void delegateSetLength(long newLength) throws IOException {
  if (delegate == null) {
    if (newLength > memoryDelegate.length) {
      createRandomAccessFile();
    }
 else {
      length=(int)newLength;
    }
    return;
  }
  delegate.setLength(newLength);
}
Program: 75202
Project: 75202
Buggy source:
protected void delegateSeek(long pos) throws IOException {
  delegate.seek(pos);
}

Fixed version (ground truth):
protected void delegateSeek(long pos) throws IOException {
  if (delegate == null) {
    if (pos > memoryDelegate.length) {
      createRandomAccessFile();
    }
 else {
      pointer=(int)pos;
      return;
    }
  }
  delegate.seek(pos);
}
Program: 75203
Project: 75203
Buggy source:
protected long delegateGetFilePointer() throws IOException {
  return delegate.getFilePointer();
}

Fixed version (ground truth):
protected long delegateGetFilePointer() throws IOException {
  if (delegate == null) {
    return pointer;
  }
  return delegate.getFilePointer();
}
Program: 75204
Project: 75204
Buggy source:
protected long delegateLength() throws IOException {
  return delegate.length();
}

Fixed version (ground truth):
protected long delegateLength() throws IOException {
  if (delegate == null) {
    return length;
  }
  return delegate.length();
}
Program: 75205
Project: 75205
Buggy source:
protected void delegateWrite(byte[] b,int pos,int len) throws IOException {
  delegate.write(b,pos,len);
}

Fixed version (ground truth):
protected void delegateWrite(byte[] b,int pos,int len) throws IOException {
  if (delegate == null) {
    if (pointer + len > memoryDelegate.length) {
      createRandomAccessFile();
    }
 else {
      System.arraycopy(b,pos,memoryDelegate,pointer,len);
      if (pointer + len > length) {
        length=pointer + len;
      }
      pointer+=len;
      return;
    }
  }
  delegate.write(b,pos,len);
}
Program: 75206
Project: 75206
Buggy source:
/** 
 * Get page number by bookmark.
 * @param params
 * @param bean
 * @param document
 * @return
 * @throws RemoteException
 */
protected String getBookmark(Oprand[] params,BaseAttributeBean bean){
}

Fixed version (ground truth):
/** 
 * Get bookmark name from SOAP params and request.
 * @param params
 * @param bean
 * @return
 */
protected String getBookmark(Oprand[] params,BaseAttributeBean bean){
}
Program: 75207
Project: 75207
Buggy source:
/** 
 * Get page number from incoming soap request.
 * @param params
 * @param document
 * @return
 * @throws RemoteException
 * @throws ReportServiceException
 */
protected long getPageNumber(HttpServletRequest request,Oprand[] params,String documentName) throws RemoteException, ReportServiceException {
  long pageNumber=-1;
  if (params != null && params.length > 0) {
    for (int i=0; i < params.length; i++) {
      if (IBirtConstants.OPRAND_PAGENO.equalsIgnoreCase(params[i].getName())) {
        try {
          pageNumber=Integer.parseInt(params[i].getValue());
        }
 catch (        NumberFormatException e) {
          pageNumber=-1;
        }
        InputOptions options=new InputOptions();
        options.setOption(InputOptions.OPT_REQUEST,request);
        if (pageNumber <= 0 || pageNumber > getReportService().getPageCount(documentName,options,new OutputOptions())) {
          AxisFault fault=new AxisFault();
          fault.setFaultCode(new QName("String_Node_Str"));
          fault.setFaultString("String_Node_Str");
          throw fault;
        }
        break;
      }
    }
  }
  return pageNumber;
}

Fixed version (ground truth):
/** 
 * Get page number from incoming soap request.
 * @param request
 * @param params
 * @param document
 * @return
 * @throws RemoteException
 * @throws ReportServiceException
 */
protected long getPageNumber(HttpServletRequest request,Oprand[] params,String documentName) throws RemoteException, ReportServiceException {
  long pageNumber=-1;
  if (params != null && params.length > 0) {
    for (int i=0; i < params.length; i++) {
      if (IBirtConstants.OPRAND_PAGENO.equalsIgnoreCase(params[i].getName())) {
        try {
          pageNumber=Integer.parseInt(params[i].getValue());
        }
 catch (        NumberFormatException e) {
          pageNumber=-1;
        }
        InputOptions options=new InputOptions();
        options.setOption(InputOptions.OPT_REQUEST,request);
        if (pageNumber <= 0 || pageNumber > getReportService().getPageCount(documentName,options,new OutputOptions())) {
          AxisFault fault=new AxisFault();
          fault.setFaultCode(new QName("String_Node_Str"));
          fault.setFaultString("String_Node_Str");
          throw fault;
        }
        break;
      }
    }
  }
  return pageNumber;
}
Program: 75208
Project: 75208
Buggy source:
protected void __execute() throws Exception {
  BaseAttributeBean attrBean=(BaseAttributeBean)context.getBean();
  boolean svgFlag=getSVGFlag(operation.getOprand());
  runReport();
  String bookmark=null;
  boolean useBookmark=false;
  String docName=attrBean.getReportDocumentName();
  long pageNumber=getPageNumber(context.getRequest(),operation.getOprand(),docName);
  if (!isValidPageNumber(context.getRequest(),pageNumber,docName)) {
    bookmark=getBookmark(operation.getOprand(),attrBean);
    if (bookmark != null && bookmark.length() > 0) {
      InputOptions options=new InputOptions();
      options.setOption(InputOptions.OPT_REQUEST,context.getRequest());
      options.setOption(InputOptions.OPT_LOCALE,attrBean.getLocale());
      if (attrBean.isToc()) {
        bookmark=(getReportService()).findTocByName(docName,bookmark,options);
      }
      pageNumber=getReportService().getPageNumberByBookmark(docName,bookmark,options);
      if (!isValidPageNumber(context.getRequest(),pageNumber,docName)) {
        AxisFault fault=new AxisFault();
        fault.setFaultReason(BirtResources.getMessage(ResourceConstants.ACTION_EXCEPTION_INVALID_BOOKMARK,new String[]{getBookmark(operation.getOprand(),attrBean)}));
        throw fault;
      }
      useBookmark=true;
    }
  }
  doRenderPage(docName,pageNumber,attrBean.getFormat(),svgFlag,attrBean.isMasterPageContent(),useBookmark,bookmark,attrBean.getLocale(),attrBean.isRtl());
}

Fixed version (ground truth):
protected void __execute() throws Exception {
  BaseAttributeBean attrBean=(BaseAttributeBean)context.getBean();
  boolean svgFlag=getSVGFlag(operation.getOprand());
  runReport();
  String bookmark=null;
  boolean useBookmark=false;
  String docName=attrBean.getReportDocumentName();
  long pageNumber=getPageNumber(context.getRequest(),operation.getOprand(),docName);
  if (!isValidPageNumber(context.getRequest(),pageNumber,docName)) {
    bookmark=getBookmark(operation.getOprand(),attrBean);
    if (bookmark != null && bookmark.length() > 0) {
      InputOptions options=new InputOptions();
      options.setOption(InputOptions.OPT_REQUEST,context.getRequest());
      options.setOption(InputOptions.OPT_LOCALE,attrBean.getLocale());
      if (isToc(operation.getOprand(),attrBean)) {
        bookmark=(getReportService()).findTocByName(docName,bookmark,options);
      }
      pageNumber=getReportService().getPageNumberByBookmark(docName,bookmark,options);
      if (!isValidPageNumber(context.getRequest(),pageNumber,docName)) {
        AxisFault fault=new AxisFault();
        fault.setFaultReason(BirtResources.getMessage(ResourceConstants.ACTION_EXCEPTION_INVALID_BOOKMARK,new String[]{getBookmark(operation.getOprand(),attrBean)}));
        throw fault;
      }
      useBookmark=true;
    }
  }
  doRenderPage(docName,pageNumber,attrBean.getFormat(),svgFlag,attrBean.isMasterPageContent(),useBookmark,bookmark,attrBean.getLocale(),attrBean.isRtl());
}
Program: 75211
Project: 75211
Buggy source:
protected void loggerParamters(){
  if (log.isLoggable(Level.FINE)) {
    final StringBuffer buffer=new StringBuffer();
    new ParameterVisitor(){
      boolean visitScalarParameter(      ScalarParameterHandle param,      Object value){
        String paramName=param.getName();
        Object paramValue=runValues.get(paramName);
        buffer.append(paramName);
        buffer.append("String_Node_Str");
        buffer.append(paramValue);
        buffer.append("String_Node_Str");
        return validateScalarParameter(param);
      }
      boolean visitParameterGroup(      ParameterGroupHandle group,      Object value){
        return visitParametersInGroup(group,value);
      }
    }
.visit((ReportDesignHandle)runnable.getDesignHandle(),null);
    log.log(Level.FINE,"String_Node_Str",buffer);
  }
}

Fixed version (ground truth):
protected void loggerParamters(){
  if (log.isLoggable(Level.FINE)) {
    final StringBuffer buffer=new StringBuffer();
    new ParameterVisitor(){
      boolean visitScalarParameter(      ScalarParameterHandle param,      Object value){
        String paramName=param.getName();
        Object paramValue=runValues.get(paramName);
        buffer.append(paramName);
        buffer.append("String_Node_Str");
        buffer.append(paramValue);
        buffer.append("String_Node_Str");
        return true;
      }
      boolean visitParameterGroup(      ParameterGroupHandle group,      Object value){
        return visitParametersInGroup(group,value);
      }
    }
.visit((ReportDesignHandle)runnable.getDesignHandle(),null);
    log.log(Level.FINE,"String_Node_Str",buffer);
  }
}
Program: 75213
Project: 75213
Buggy source:
public boolean validateParameters(){
  if (runnable == null) {
    return false;
  }
  usingParameterValues();
  if (log.isLoggable(Level.FINE)) {
    loggerParamters();
  }
  return new ParameterVisitor(){
    boolean visitScalarParameter(    ScalarParameterHandle param,    Object value){
      return validateScalarParameter(param);
    }
    boolean visitParameterGroup(    ParameterGroupHandle group,    Object value){
      return visitParametersInGroup(group,value);
    }
  }
.visit((ReportDesignHandle)runnable.getDesignHandle(),null);
}

Fixed version (ground truth):
public boolean validateParameters(){
  if (runnable == null) {
    return false;
  }
  try {
    doValidateParameters();
    return true;
  }
 catch (  ParameterValidationException ex) {
    log.log(Level.SEVERE,ex.getMessage(),ex);
  }
  return false;
}
Program: 75216
Project: 75216
Buggy source:
public IReportItemExecutor getNextChild(){
  if (childContent != null) {
    IReportItemExecutor ret=new ItemExecutorWrapper(childExecutor,childContent);
    childContent=null;
    childExecutor=null;
    needUpdate=true;
    return ret;
  }
  if (currentRunIn != null) {
    needUpdate=true;
    IReportItemExecutor runInChild=currentRunIn.getNextChild();
    if (runInChild != null) {
      IContent runInContent=runInChild.execute();
      if (runInContent != null && (runInContent.getChildren() == null || runInContent.getChildren().size() == 0)) {
        execute(runInChild,runInContent);
        runInChild.close();
        runInChild=new DOMReportItemExecutor(runInContent);
      }
    }
    return runInChild;
  }
  assert(false);
  return null;
}

Fixed version (ground truth):
public IReportItemExecutor getNextChild(){
  if (childContent != null) {
    IReportItemExecutor ret=new ItemExecutorWrapper(childExecutor,childContent);
    childContent=null;
    childExecutor=null;
    needUpdate=true;
    return ret;
  }
  if (currentRunIn != null) {
    needUpdate=true;
    IReportItemExecutor runInChild=currentRunIn.getNextChild();
    if (runInChild != null) {
      IContent runInContent=runInChild.execute();
      if (firstChild) {
        transferPageBreak(currentRunInContent,runInContent);
        firstChild=false;
      }
      if (runInContent != null && (runInContent.getChildren() == null || runInContent.getChildren().size() == 0)) {
        execute(runInChild,runInContent);
        runInChild.close();
        runInChild=new DOMReportItemExecutor(runInContent);
      }
    }
    return runInChild;
  }
  assert(false);
  return null;
}
Program: 75217
Project: 75217
Buggy source:
public boolean hasNextChild(){
  if (!needUpdate) {
    return hasNext;
  }
  if (currentRunIn != null) {
    if (currentRunIn.hasNextChild()) {
      hasNext=true;
      needUpdate=false;
      return hasNext;
    }
 else {
      currentRunIn.close();
    }
  }
  currentRunIn=null;
  while (executor.hasNextChild()) {
    IReportItemExecutor next=executor.getNextChild();
    IContent nextContent=next.execute();
    if (nextContent instanceof IListBandContent) {
      IListBandContent band=(IListBandContent)nextContent;
      if (repeat && (band.getBandType() == IBandContent.BAND_HEADER || band.getBandType() == IBandContent.BAND_GROUP_HEADER)) {
        executeHeader(next,nextContent);
        next.close();
        next=new DOMReportItemExecutor(nextContent);
        next.execute();
        add(nextContent.getParent().getChildren(),nextContent);
      }
      if (next.hasNextChild()) {
        currentRunIn=next;
        break;
      }
    }
 else {
      childExecutor=next;
      childContent=nextContent;
      break;
    }
  }
  if (currentRunIn != null || childContent != null) {
    hasNext=true;
  }
 else {
    hasNext=false;
  }
  needUpdate=false;
  return hasNext;
}

Fixed version (ground truth):
public boolean hasNextChild(){
  if (!needUpdate) {
    return hasNext;
  }
  if (currentRunIn != null) {
    if (currentRunIn.hasNextChild()) {
      hasNext=true;
      needUpdate=false;
      return hasNext;
    }
 else {
      currentRunIn.close();
    }
  }
  currentRunIn=null;
  while (executor.hasNextChild()) {
    IReportItemExecutor next=executor.getNextChild();
    IContent nextContent=next.execute();
    if (nextContent instanceof IListBandContent) {
      IListBandContent band=(IListBandContent)nextContent;
      if (repeat && (band.getBandType() == IBandContent.BAND_HEADER || band.getBandType() == IBandContent.BAND_GROUP_HEADER)) {
        executeHeader(next,nextContent);
        next.close();
        next=new DOMReportItemExecutor(nextContent);
        next.execute();
        add(nextContent.getParent().getChildren(),nextContent);
      }
      if (next.hasNextChild()) {
        currentRunIn=next;
        currentRunInContent=nextContent;
        firstChild=true;
        break;
      }
    }
 else {
      childExecutor=next;
      childContent=nextContent;
      break;
    }
  }
  if (currentRunIn != null || childContent != null) {
    hasNext=true;
  }
 else {
    hasNext=false;
  }
  needUpdate=false;
  return hasNext;
}
Program: 75218
Project: 75218
Buggy source:
/** 
 * fill empty cells in the table.
 * @param rowId row index
 * @param colId col index
 * @param rowSize fill area size
 * @param colSize fill area size
 */
protected void fillEmptyCells(int rowId,int colId,int rowSize,int colSize){
  int lastRowId=rowId + rowSize;
  int lastColId=colId + colSize;
  if (lastRowId > rowCount)   lastRowId=rowCount;
  if (lastColId > colCount)   lastColId=colCount;
  for (int i=rowId; i < lastRowId; i++) {
    Cell[] cells=rows[i].cells;
    for (int j=colId; j < lastColId; j++) {
      cells[j]=Cell.EMPTY_CELL;
    }
  }
}

Fixed version (ground truth):
/** 
 * fill empty cells in the table.
 * @param rowId row index
 * @param colId col index
 * @param rowSize fill area size
 * @param colSize fill area size
 */
protected void fillEmptyCells(int rowId,int colId,int rowSize,int colSize){
  int lastRowId=rowId + rowSize;
  int lastColId=colId + colSize;
  if (lastRowId > rowCount)   lastRowId=rowCount;
  if (lastColId > colCount)   lastColId=colCount;
  if (lastRowId > 0 && rows[lastRowId - 1] != null) {
    lastRow=new Row(rows[lastRowId - 1].rowId);
    lastRow.content=rows[lastRowId - 1].content;
    lastRow.cells=new Cell[lastColId - colId];
    for (int i=colId; i < lastColId; i++) {
      lastRow.cells[i]=rows[lastRowId - 1].cells[i];
    }
  }
  for (int i=rowId; i < lastRowId; i++) {
    Cell[] cells=rows[i].cells;
    for (int j=colId; j < lastColId; j++) {
      cells[j]=Cell.EMPTY_CELL;
    }
  }
}
Program: 75219
Project: 75219
Buggy source:
protected void keepUnresolvedCells(){
  if (rowCount <= 0) {
    return;
  }
  if (rowHint == null) {
    Row row=rows[rowCount - 1];
    Cell[] cells=rows[rowCount - 1].cells;
    IRowContent rowContent=(IRowContent)row.getContent();
    ITableContent table=rowContent.getTable();
    InstanceID tableId=table.getInstanceID();
    InstanceID rowId=rowContent.getInstanceID();
    UnresolvedRowHint hint=new UnresolvedRowHint(tableId.toUniqueString(),rowId.toUniqueString());
    for (int cellId=0; cellId < realColCount; cellId++) {
      if (cells[cellId] != null) {
        String style=null;
        CellContent cellContent=(CellContent)cells[cellId].getContent();
        if (cellContent != null) {
          ICellContent cc=cellContent.getContent();
          if (cc != null) {
            style=cc.getStyle().getCssText();
          }
        }
        hint.addUnresolvedCell(style,cells[cellId].getColId(),cells[cellId].getColSpan(),cells[cellId].getRowSpan());
      }
    }
    this.rowHint=hint;
  }
}

Fixed version (ground truth):
protected void keepUnresolvedCells(){
  if (rowHint == null) {
    Row row=null;
    if (rowCount > 0) {
      row=rows[rowCount - 1];
    }
 else     if (lastRow != null) {
      row=lastRow;
    }
 else {
      return;
    }
    Cell[] cells=row.cells;
    IRowContent rowContent=(IRowContent)row.getContent();
    ITableContent table=rowContent.getTable();
    InstanceID tableId=table.getInstanceID();
    InstanceID rowId=rowContent.getInstanceID();
    UnresolvedRowHint hint=new UnresolvedRowHint(tableId.toUniqueString(),rowId.toUniqueString());
    for (int cellId=0; cellId < realColCount; cellId++) {
      if (cells[cellId] != null) {
        String style=null;
        CellContent cellContent=(CellContent)cells[cellId].getContent();
        if (cellContent != null) {
          ICellContent cc=cellContent.getContent();
          if (cc != null) {
            style=cc.getStyle().getCssText();
          }
        }
        hint.addUnresolvedCell(style,cells[cellId].getColId(),cells[cellId].getColSpan(),cells[cellId].getRowSpan());
      }
    }
    this.rowHint=hint;
  }
}
Program: 75222
Project: 75222
Buggy source:
private TableLayoutInfo resolveTableLayoutInfo(TableArea area){
  assert(parent != null);
  int avaWidth=parent.getCurrentMaxContentWidth() - parent.getCurrentIP();
  int parentMaxWidth=parent.getCurrentMaxContentWidth();
  IStyle style=area.getStyle();
  validateBoxProperty(style);
  int marginWidth=getDimensionValue(style.getProperty(StyleConstants.STYLE_MARGIN_LEFT)) + getDimensionValue(style.getProperty(StyleConstants.STYLE_MARGIN_RIGHT));
  int specifiedWidth=getDimensionValue(tableContent.getWidth(),parentMaxWidth);
  if (specifiedWidth + marginWidth > parentMaxWidth) {
    specifiedWidth=0;
  }
  boolean isInline=PropertyUtil.isInlineElement(content);
  if (specifiedWidth == 0) {
    if (isInline) {
      if (avaWidth - marginWidth > parentMaxWidth / 4) {
        tableWidth=avaWidth - marginWidth;
      }
 else {
        tableWidth=parentMaxWidth - marginWidth;
      }
    }
 else {
      tableWidth=avaWidth - marginWidth;
    }
    return new TableLayoutInfo(handleColummVisibity(columnWidthResolver.resolve(tableWidth,tableWidth)));
  }
 else {
    if (!isInline) {
      tableWidth=Math.min(specifiedWidth,avaWidth - marginWidth);
      return new TableLayoutInfo(handleColummVisibity(columnWidthResolver.resolve(tableWidth,avaWidth - marginWidth)));
    }
 else {
      tableWidth=Math.min(specifiedWidth,parentMaxWidth - marginWidth);
      return new TableLayoutInfo(handleColummVisibity(columnWidthResolver.resolve(tableWidth,parentMaxWidth - marginWidth)));
    }
  }
}

Fixed version (ground truth):
private TableLayoutInfo resolveTableLayoutInfo(TableArea area){
  assert(parent != null);
  int avaWidth=parent.getCurrentMaxContentWidth() - parent.getCurrentIP();
  int parentMaxWidth=parent.getCurrentMaxContentWidth();
  IStyle style=area.getStyle();
  validateBoxProperty(style);
  int marginWidth=getDimensionValue(style.getProperty(StyleConstants.STYLE_MARGIN_LEFT)) + getDimensionValue(style.getProperty(StyleConstants.STYLE_MARGIN_RIGHT));
  int specifiedWidth=getDimensionValue(tableContent.getWidth(),parentMaxWidth);
  if (specifiedWidth + marginWidth > parentMaxWidth) {
    specifiedWidth=0;
  }
  boolean isInline=PropertyUtil.isInlineElement(content);
  if (specifiedWidth == 0) {
    if (isInline) {
      if (avaWidth - marginWidth > parentMaxWidth / 4) {
        tableWidth=avaWidth - marginWidth;
      }
 else {
        tableWidth=parentMaxWidth - marginWidth;
      }
    }
 else {
      tableWidth=avaWidth - marginWidth;
    }
    return new TableLayoutInfo(handleColumnVisibility(columnWidthResolver.resolve(tableWidth,tableWidth)));
  }
 else {
    if (!isInline) {
      tableWidth=Math.min(specifiedWidth,avaWidth - marginWidth);
      return new TableLayoutInfo(handleColumnVisibility(columnWidthResolver.resolve(tableWidth,avaWidth - marginWidth)));
    }
 else {
      tableWidth=Math.min(specifiedWidth,parentMaxWidth - marginWidth);
      return new TableLayoutInfo(handleColumnVisibility(columnWidthResolver.resolve(tableWidth,parentMaxWidth - marginWidth)));
    }
  }
}
Program: 75223
Project: 75223
Buggy source:
protected void mergeDropCell(RowArea row){
  if (unresolvedRow == null) {
    return;
  }
  CellArea[] cells=new CellArea[columnNumber];
  Iterator iter=row.getChildren();
  while (iter.hasNext()) {
    CellArea cell=(CellArea)iter.next();
    int colStart=cell.getColumnID();
    int colEnd=colStart + cell.getColSpan();
    for (int i=colStart; i < colEnd; i++) {
      int index=colStart - start;
      if (index >= 0 && index < columnNumber) {
        cells[colStart - start]=cell;
      }
    }
  }
  for (int i=0; i < columnNumber; i++) {
    if (cells[i] == null) {
      ICellContent cellContent=null;
      CellArea ca=unresolvedRow.getCell(start + i);
      if (ca != null) {
        ICellContent cc=(ICellContent)ca.getContent();
        cellContent=new ClonedCellContent(cc,getRowSpan((IRowContent)row.getContent(),ca,unresolvedRow.row));
        int startColumn=cellContent.getColumn();
        int endColumn=cellContent.getColSpan() + startColumn;
        CellArea emptyCell=AreaFactory.createCellArea(cellContent);
        emptyCell.setRowSpan(cellContent.getRowSpan());
        resolveBorderConflict(emptyCell,false);
        emptyCell.setWidth(getCellWidth(startColumn,endColumn));
        emptyCell.setPosition(layoutInfo.getXPosition(i),0);
        emptyCell.setHeight(row.getHeight());
        row.addChild(emptyCell);
      }
    }
  }
}

Fixed version (ground truth):
protected void mergeDropCell(RowArea row){
  if (unresolvedRow == null) {
    return;
  }
  CellArea[] cells=new CellArea[columnNumber];
  Iterator iter=row.getChildren();
  while (iter.hasNext()) {
    CellArea cell=(CellArea)iter.next();
    int colStart=cell.getColumnID();
    int colEnd=colStart + cell.getColSpan();
    for (int i=colStart; i < colEnd; i++) {
      int index=colStart - start;
      if (index >= 0 && index < columnNumber) {
        cells[colStart - start]=cell;
      }
    }
  }
  for (int i=0; i < columnNumber; i++) {
    if (cells[i] == null) {
      ICellContent cellContent=null;
      CellArea ca=unresolvedRow.getCell(start + i);
      if (ca != null) {
        ICellContent cc=(ICellContent)ca.getContent();
        cellContent=new ClonedCellContent(cc,getRowSpan((IRowContent)row.getContent(),ca,unresolvedRow.row));
        int startColumn=cellContent.getColumn();
        int endColumn=cellContent.getColSpan() + startColumn;
        CellArea emptyCell=AreaFactory.createCellArea(cellContent);
        emptyCell.setRowSpan(cellContent.getRowSpan());
        resolveBorderConflict(emptyCell,true);
        emptyCell.setWidth(getCellWidth(startColumn,endColumn));
        emptyCell.setPosition(layoutInfo.getXPosition(i),0);
        emptyCell.setHeight(row.getHeight());
        row.addChild(emptyCell);
      }
    }
  }
}
Program: 75224
Project: 75224
Buggy source:
/** 
 * Get styles
 * @param comparator
 * @return return styles list sortted with given comparator.
 */
public static Iterator getStyles(Comparator comparator){
  List styles=null;
  if (SessionHandleAdapter.getInstance().getReportDesignHandle() instanceof ReportDesignHandle) {
    styles=SessionHandleAdapter.getInstance().getReportDesignHandle().getAllStyles();
  }
 else   if (SessionHandleAdapter.getInstance().getReportDesignHandle() instanceof LibraryHandle) {
    styles=new ArrayList();
    ThemeHandle theme=((LibraryHandle)SessionHandleAdapter.getInstance().getReportDesignHandle()).getTheme();
    if (theme != null) {
      styles.addAll(theme.getAllStyles());
    }
  }
  Object[] stylesArray=(styles == null ? new Object[0] : styles.toArray());
  if (comparator != null) {
    Arrays.sort(stylesArray,comparator);
  }
  return Arrays.asList(stylesArray).iterator();
}

Fixed version (ground truth):
/** 
 * Get styles
 * @param comparator
 * @return return styles list sortted with given comparator.
 */
public static Iterator getStyles(ThemeHandle theme,Comparator comparator){
  List styles=new ArrayList();
  if (theme != null) {
    styles.addAll(theme.getAllStyles());
  }
 else   if (SessionHandleAdapter.getInstance().getReportDesignHandle() instanceof LibraryHandle) {
    styles=new ArrayList();
    theme=((LibraryHandle)SessionHandleAdapter.getInstance().getReportDesignHandle()).getTheme();
    if (theme != null) {
      styles.addAll(theme.getAllStyles());
    }
  }
  Object[] stylesArray=styles.toArray(new Object[styles.size()]);
  if (comparator != null) {
    Arrays.sort(stylesArray,comparator);
  }
  return Arrays.asList(stylesArray).iterator();
}
Program: 75225
Project: 75225
Buggy source:
protected DesignElementHandle createElement(SlotHandle slotHandle,String type) throws Exception {
  DesignElementFactory factory=DesignElementFactory.getInstance();
  DesignElementHandle handle=factory.newStyle((ThemeHandle)slotHandle.getElementHandle(),null);
  if (ProviderFactory.createProvider(handle).performRequest(handle,new Request(IRequestConstants.REQUEST_TYPE_EDIT))) {
    return handle;
  }
  return null;
}

Fixed version (ground truth):
protected DesignElementHandle createElement(SlotHandle slotHandle,String type) throws Exception {
  ThemeHandle theme=(ThemeHandle)slotHandle.getElementHandle();
  DesignElementFactory factory=DesignElementFactory.getInstance();
  SharedStyleHandle handle=factory.newStyle(theme,null);
  StyleBuilder builder=new StyleBuilder(PlatformUI.getWorkbench().getDisplay().getActiveShell(),handle,theme,StyleBuilder.DLG_TITLE_NEW);
  if (builder.open() == Dialog.CANCEL) {
    return null;
  }
  return handle;
}
Program: 75227
Project: 75227
Buggy source:
/** 
 * Default constructor.
 * @param model,the model of preference page.
 */
public GeneralPreferencePage(Object model){
  super(model);
  this.model=model;
}

Fixed version (ground truth):
/** 
 * Constructor with theme.
 * @param model
 * @param theme
 */
public GeneralPreferencePage(Object model,ThemeHandle theme){
  super(model);
  this.model=model;
  this.theme=theme;
}
Program: 75228
Project: 75228
Buggy source:
private boolean checkName(String name,boolean showError){
  String trimName=name.trim();
  Iterator iterator=DEUtil.getStyles();
  while (iterator.hasNext()) {
    SharedStyleHandle handle=(SharedStyleHandle)iterator.next();
    if ((handle.getName() != null) && handle.getName().equals(trimName) && (handle != model)) {
      if (showError) {
        ExceptionHandler.openErrorMessageBox(Messages.getString("String_Node_Str"),Messages.getFormattedString("String_Node_Str",new String[]{name}));
      }
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean checkName(String name,boolean showError){
  String trimName=name.trim();
  Iterator iterator=null;
  if (theme != null) {
    iterator=DEUtil.getStyles(theme);
  }
 else {
    iterator=DEUtil.getLocalStyles();
  }
  while (iterator.hasNext()) {
    SharedStyleHandle handle=(SharedStyleHandle)iterator.next();
    if ((handle.getName() != null) && handle.getName().equals(trimName) && (handle != model)) {
      if (showError) {
        ExceptionHandler.openErrorMessageBox(Messages.getString("String_Node_Str"),Messages.getFormattedString("String_Node_Str",new String[]{name}));
      }
      return false;
    }
  }
  return true;
}
Program: 75229
Project: 75229
Buggy source:
/** 
 * Runs action.
 */
public void run(){
  if (themeHandle != null) {
    CommandUtils.setVariable(ICommandParameterNameContants.NEW_STYLE_THEME_HANDLE_NAME,themeHandle);
  }
  try {
    CommandUtils.executeCommand("String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    if (themeHandle != null) {
      CommandUtils.removeVariable(ICommandParameterNameContants.NEW_STYLE_THEME_HANDLE_NAME);
    }
  }
}

Fixed version (ground truth):
/** 
 * Runs action.
 */
public void run(){
  boolean hasTheme=false;
  if (themeHandle != null) {
    hasTheme=true;
    CommandUtils.setVariable(ICommandParameterNameContants.NEW_STYLE_THEME_HANDLE_NAME,themeHandle);
  }
 else   if (SessionHandleAdapter.getInstance().getReportDesignHandle() instanceof LibraryHandle) {
    ThemeHandle theme=((LibraryHandle)SessionHandleAdapter.getInstance().getReportDesignHandle()).getTheme();
    if (theme != null) {
      hasTheme=true;
      CommandUtils.setVariable(ICommandParameterNameContants.NEW_STYLE_THEME_HANDLE_NAME,theme);
    }
  }
  try {
    CommandUtils.executeCommand("String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    if (hasTheme) {
      CommandUtils.removeVariable(ICommandParameterNameContants.NEW_STYLE_THEME_HANDLE_NAME);
    }
  }
}
Program: 75230
Project: 75230
Buggy source:
/** 
 * Constructor
 * @param parentShell
 * @param handle
 */
public StyleBuilder(Shell parentShell,ReportElementHandle handle,String title){
  super(parentShell,createPreferenceManager(handle));
  this.title=title;
}

Fixed version (ground truth):
/** 
 * Constructor
 * @param parentShell
 * @param handle
 */
public StyleBuilder(Shell parentShell,ReportElementHandle handle,ThemeHandle theme,String title){
  super(parentShell,createPreferenceManager(handle,theme));
  this.title=title;
}
Program: 75231
Project: 75231
Buggy source:
private static PreferenceManager createPreferenceManager(ReportElementHandle handle){
  PreferenceManager preferenceManager=new PreferenceManager('/');
  List pageContributions=new ArrayList();
  pageContributions.add(new PreferenceNode("String_Node_Str",new GeneralPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new FontPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new BackgroundPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new BlockPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new BoxPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new BorderPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new FormatNumberPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new FormatDateTimePreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new FormatStringPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new PageBreakPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new MapPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new HighlightsPreferencePage(handle)));
  Iterator it=pageContributions.iterator();
  while (it.hasNext()) {
    preferenceManager.addToRoot((IPreferenceNode)it.next());
  }
  return preferenceManager;
}

Fixed version (ground truth):
private static PreferenceManager createPreferenceManager(ReportElementHandle handle,ThemeHandle theme){
  PreferenceManager preferenceManager=new PreferenceManager('/');
  List pageContributions=new ArrayList();
  pageContributions.add(new PreferenceNode("String_Node_Str",new GeneralPreferencePage(handle,theme)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new FontPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new BackgroundPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new BlockPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new BoxPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new BorderPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new FormatNumberPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new FormatDateTimePreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new FormatStringPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new PageBreakPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new MapPreferencePage(handle)));
  pageContributions.add(new PreferenceNode("String_Node_Str",new HighlightsPreferencePage(handle)));
  Iterator it=pageContributions.iterator();
  while (it.hasNext()) {
    preferenceManager.addToRoot((IPreferenceNode)it.next());
  }
  return preferenceManager;
}
Program: 75232
Project: 75232
Buggy source:
/** 
 * @param groupLevel
 * @throws DataException
 * @throws BirtException
 */
protected void goThroughGapRows(int groupLevel) throws DataException, BirtException {
  while (groupLevel < odiResult.getEndingGroupLevel() && odiResult.getEndingGroupLevel() != 0 && odiResult.next()) {
    this.prepareCurrentRow();
  }
}

Fixed version (ground truth):
/** 
 * @param groupLevel
 * @throws DataException
 * @throws BirtException
 */
protected void goThroughGapRows(int groupLevel) throws DataException, BirtException {
  while (groupLevel < odiResult.getEndingGroupLevel() && odiResult.getEndingGroupLevel() != 0 && odiResult.next()) {
    clear();
    this.prepareCurrentRow();
  }
}
Program: 75233
Project: 75233
Buggy source:
public void moveTo(int rowIndex) throws BirtException {
  checkStarted();
  if (state == BEFORE_FIRST_ROW) {
    this.prepareCurrentRow();
    state=ON_ROW;
  }
  int currRowIndex=odiResult.getCurrentResultIndex();
  if (rowIndex < 0 || rowIndex >= this.odiResult.getRowCount())   throw new DataException(ResourceConstants.INVALID_ROW_INDEX,new Integer(rowIndex));
 else   if (rowIndex < currRowIndex)   throw new DataException(ResourceConstants.BACKWARD_SEEK_ERROR);
 else   if (rowIndex == currRowIndex)   return;
  int gapRows=rowIndex - currRowIndex;
  for (int i=0; i < gapRows; i++)   this.next();
}

Fixed version (ground truth):
public void moveTo(int rowIndex) throws BirtException {
  checkStarted();
  if (state == BEFORE_FIRST_ROW) {
    clear();
    this.prepareCurrentRow();
    state=ON_ROW;
  }
  int currRowIndex=odiResult.getCurrentResultIndex();
  if (rowIndex < 0 || rowIndex >= this.odiResult.getRowCount())   throw new DataException(ResourceConstants.INVALID_ROW_INDEX,new Integer(rowIndex));
 else   if (rowIndex < currRowIndex)   throw new DataException(ResourceConstants.BACKWARD_SEEK_ERROR);
 else   if (rowIndex == currRowIndex)   return;
  int gapRows=rowIndex - currRowIndex;
  for (int i=0; i < gapRows; i++)   this.next();
}
Program: 75234
Project: 75234
Buggy source:
private void testPriority(final String testDir){
  FontConfigReader reader=new FontConfigReader(){
    protected URL getURL(    String configFile){
      URL fileURL=getClass().getResource("String_Node_Str" + testDir + "String_Node_Str"+ configFile);
      return fileURL;
    }
  }
;
  reader.initialize();
  FontMappingManager manager=reader.getFontMappingManager();
  testMergedProperty(manager.getFontAliases(),8);
  testMergedProperty(manager.getFontEncodings(),9);
  Map compositeFonts=manager.getCompositeFonts();
  assertEquals(3,compositeFonts.size());
  String fontName="String_Node_Str";
  compositeFonts.get(fontName);
  Map compositeFont1=(Map)compositeFonts.get(fontName);
  assertEquals(1,compositeFont1.size());
  assertTrue(compositeFonts.containsKey("String_Node_Str"));
  assertTrue(compositeFonts.containsKey("String_Node_Str"));
}

Fixed version (ground truth):
private void testPriority(final String testDir,String format){
  FontConfigReader reader=new FontConfigReader(){
    protected URL getURL(    String configFile){
      URL fileURL=getClass().getResource("String_Node_Str" + testDir + "String_Node_Str"+ configFile);
      return fileURL;
    }
  }
;
  reader.initialize();
  FontMappingManager manager=null;
  if (format == null) {
    manager=reader.getFontMappingManager();
  }
 else {
    reader.parseFormatRelatedConfigFile(format);
    manager=reader.getFontMappingManager();
  }
  testMergedProperty(manager.getFontAliases(),8);
  testMergedProperty(manager.getFontEncodings(),9);
  Map compositeFonts=manager.getCompositeFonts();
  assertEquals(3,compositeFonts.size());
  String fontName="String_Node_Str";
  compositeFonts.get(fontName);
  Map compositeFont1=(Map)compositeFonts.get(fontName);
  assertEquals(1,compositeFont1.size());
  assertTrue(compositeFonts.containsKey("String_Node_Str"));
  assertTrue(compositeFonts.containsKey("String_Node_Str"));
}
Program: 75238
Project: 75238
Buggy source:
protected String handleTempImage(IImage image,String prefix,boolean needMap){
  try {
    File imageFile=File.createTempFile(prefix,"String_Node_Str");
    image.writeImage(imageFile);
    String fileName=imageFile.getAbsolutePath();
    if (needMap) {
      String mapID=getImageMapID(image);
      map.put(mapID,fileName);
    }
    return fileName;
  }
 catch (  IOException e) {
    log.log(Level.SEVERE,e.getMessage(),e);
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
protected String handleTempImage(IImage image,String prefix,boolean needMap){
  try {
    File imageFile=File.createTempFile(prefix,"String_Node_Str");
    image.writeImage(imageFile);
    String fileName=imageFile.getAbsolutePath();
    if (needMap) {
      String mapID=getImageMapID(image);
synchronized (map) {
        map.put(mapID,fileName);
      }
    }
    return fileName;
  }
 catch (  IOException e) {
    log.log(Level.SEVERE,e.getMessage(),e);
  }
  return "String_Node_Str";
}
Program: 75244
Project: 75244
Buggy source:
public void startForeign(IForeignContent foreign){
  if (IForeignContent.HTML_TYPE.equalsIgnoreCase(foreign.getRawType())) {
    HTML2Content convert=new HTML2Content(foreign.getReportContent().getDesign().getReportDesign());
    convert.html2Content(foreign);
    HyperlinkDef link=parseHyperLink(foreign);
    engine.addContainer(foreign.getComputedStyle(),link);
    contentVisitor.visitChildren(foreign,null);
    engine.endContainer();
  }
}

Fixed version (ground truth):
public void startForeign(IForeignContent foreign){
  if (IForeignContent.HTML_TYPE.equalsIgnoreCase(foreign.getRawType())) {
    HTML2Content.html2Content(foreign);
    HyperlinkDef link=parseHyperLink(foreign);
    engine.addContainer(foreign.getComputedStyle(),link);
    contentVisitor.visitChildren(foreign,null);
    engine.endContainer();
  }
}
Program: 75245
Project: 75245
Buggy source:
public Object visitForeign(IForeignContent foreign,Object value){
  if (IForeignContent.HTML_TYPE.equals(foreign.getRawType())) {
    if (converter == null) {
      converter=new HTML2Content(foreign.getReportContent().getDesign().getReportDesign());
    }
    converter.html2Content(foreign);
    executor=new DOMReportItemExecutor(foreign);
    executor.execute();
    return visitContent(foreign,value);
  }
  LabelContent label=new LabelContent(foreign);
  return handleText(label);
}

Fixed version (ground truth):
public Object visitForeign(IForeignContent foreign,Object value){
  if (IForeignContent.HTML_TYPE.equals(foreign.getRawType())) {
    HTML2Content.html2Content(foreign);
    executor=new DOMReportItemExecutor(foreign);
    executor.execute();
    return visitContent(foreign,value);
  }
  LabelContent label=new LabelContent(foreign);
  return handleText(label);
}
Program: 75246
Project: 75246
Buggy source:
/** 
 * private utility method to check whether it is a long string 
 * @param str
 * @return true if it is a long string
 */
private static boolean isLongString(String str){
  int strlen=str.length();
  int utflen=0;
  int c=0;
  for (int i=0; i < strlen; i++) {
    c=str.charAt(i);
    if ((c >= 0x0001) && (c <= 0x007F)) {
      utflen++;
    }
 else     if (c > 0x07FF) {
      utflen+=3;
    }
 else {
      utflen+=2;
    }
  }
  if (utflen > 65535) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * private utility method to check whether it is a long string 
 * @param str
 * @return true if it is a long string
 */
private static boolean isLongString(String str){
  int strlen=str.length();
  if (strlen > 65535) {
    return true;
  }
 else   if (strlen < 21845) {
    return false;
  }
  int utflen=getBytesSize(str);
  if (utflen > 65535) {
    return true;
  }
 else {
    return false;
  }
}
Program: 75247
Project: 75247
Buggy source:
/** 
 * private utility method to write a UTF String to a DataOutputStream
 * @param str
 * @throws UTFDataFormatException
 */
private static void writeUTF(DataOutputStream dos,String str) throws IOException {
  byte[] longBytes=convertString2Bytes(str);
  dos.writeInt(longBytes.length);
  dos.write(longBytes,0,longBytes.length);
}

Fixed version (ground truth):
/** 
 * private utility method to write a UTF String to a DataOutputStream
 * @param str
 * @throws UTFDataFormatException
 */
private static void writeUTF(DataOutputStream dos,String str) throws IOException {
  int strlen=str.length();
  int c=0;
  int utflen=getBytesSize(str);
  dos.writeInt(utflen);
  int i=0;
  for (; i < strlen; i++) {
    c=str.charAt(i);
    if (!((c >= 0x0001) && (c <= 0x007F)))     break;
    dos.writeByte((byte)c);
  }
  for (; i < strlen; i++) {
    c=str.charAt(i);
    if ((c >= 0x0001) && (c <= 0x007F)) {
      dos.writeByte((byte)c);
    }
 else     if (c > 0x07FF) {
      dos.writeByte((byte)(0xE0 | ((c >> 12) & 0x0F)));
      dos.writeByte((byte)(0x80 | ((c >> 6) & 0x3F)));
      dos.writeByte((byte)(0x80 | ((c >> 0) & 0x3F)));
    }
 else {
      dos.writeByte((byte)(0xC0 | ((c >> 6) & 0x1F)));
      dos.writeByte((byte)(0x80 | ((c >> 0) & 0x3F)));
    }
  }
}
Program: 75248
Project: 75248
Buggy source:
/** 
 * private utility method to convert a byte[] to String
 * @param bytearre
 * @throws UTFDataFormatException
 */
private static String convertBytes2String(byte[] bytearr) throws UTFDataFormatException {
  int utflen=bytearr.length;
  char[] chararr=new char[utflen];
  int c, char2, char3;
  int count=0;
  int chararr_count=0;
  while (count < utflen) {
    c=(int)bytearr[count] & 0xff;
    if (c > 127)     break;
    count++;
    chararr[chararr_count++]=(char)c;
  }
  while (count < utflen) {
    c=(int)bytearr[count] & 0xff;
switch (c >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
      count++;
    chararr[chararr_count++]=(char)c;
  break;
case 12:
case 13:
count+=2;
if (count > utflen) throw new UTFDataFormatException("String_Node_Str");
char2=(int)bytearr[count - 1];
if ((char2 & 0xC0) != 0x80) throw new UTFDataFormatException("String_Node_Str" + count);
chararr[chararr_count++]=(char)(((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
count+=3;
if (count > utflen) throw new UTFDataFormatException("String_Node_Str");
char2=(int)bytearr[count - 2];
char3=(int)bytearr[count - 1];
if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) throw new UTFDataFormatException("String_Node_Str" + (count - 1));
chararr[chararr_count++]=(char)(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
break;
default :
throw new UTFDataFormatException("String_Node_Str" + count);
}
}
return new String(chararr,0,chararr_count);
}

Fixed version (ground truth):
/** 
 * private utility method to convert a byte[] to String
 * @param bytearre
 * @throws UTFDataFormatException
 */
private static String convertBytes2String(byte[] bytearr) throws UTFDataFormatException {
  int utflen=bytearr.length;
  char[] chararr=new char[utflen];
  int c;
  int chararr_count=0;
  int count=0;
  while (count < utflen) {
    c=(int)bytearr[count] & 0xff;
    if (c > 127)     break;
    count++;
    chararr[chararr_count++]=(char)c;
  }
  chararr_count=generateCharArray(chararr,bytearr,count,chararr_count);
  return new String(chararr,0,chararr_count);
}