nus-yam/ex-repair huggingface dataset:
Program: 72456
Project: 72456
Buggy source:
private String getImageName(String imageId,Image image) throws IOException {
  String name=(String)cachedImageSource.get(imageId);
  if (name == null) {
    name="String_Node_Str" + imageIndex++;
    cachedImageSource.put(imageId,name);
    ImageSource imageSource=getImageSource(image);
    outputNamedImageSource(name,imageSource);
  }
  return name;
}

Fixed version (ground truth):
private String getImageName(String imageId,Image image) throws IOException {
  String name=(String)cachedImageSource.get(imageId);
  if (name == null) {
    name="String_Node_Str" + imageIndex++;
    cachedImageSource.put(imageId,name);
    ArrayImageSource imageSource=getImageSource(image);
    outputNamedImageSource(name,imageSource);
  }
  return name;
}
Program: 72457
Project: 72457
Buggy source:
private void outputUncachedImage(Image image,float x,float y,float width,float height) throws IOException {
  ImageSource imageSource=getImageSource(image);
  out.print(x + "String_Node_Str" + y+ "String_Node_Str");
  out.print(width + "String_Node_Str" + height+ "String_Node_Str");
  out.print(imageSource.getWidth() + "String_Node_Str" + imageSource.getHeight());
  out.println("String_Node_Str");
  outputImageSource(imageSource,"String_Node_Str","String_Node_Str");
  out.println("String_Node_Str");
}

Fixed version (ground truth):
private void outputUncachedImage(Image image,float x,float y,float width,float height) throws IOException {
  ArrayImageSource imageSource=getImageSource(image);
  out.print(x + "String_Node_Str" + y+ "String_Node_Str");
  out.print(width + "String_Node_Str" + height+ "String_Node_Str");
  out.print(imageSource.getWidth() + "String_Node_Str" + imageSource.getHeight());
  out.println("String_Node_Str");
  outputUncachedImageSource(imageSource);
  out.println("String_Node_Str");
}
Program: 72458
Project: 72458
Buggy source:
/** 
 * Constructor.
 * @param out Output stream for PostScript output.
 * @param title title of the postscript document.
 */
public PostscriptWriter(OutputStream o,String title){
  this.out=new PrintStream(o);
  this.cachedImageSource=new HashMap();
  emitProlog(title);
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param out Output stream for PostScript output.
 * @param title title of the postscript document.
 */
public PostscriptWriter(OutputStream o,String title){
  this.out=new PrintStream(o);
  this.cachedImageSource=new HashMap<String,String>();
  emitProlog(title);
}
Program: 72459
Project: 72459
Buggy source:
private void outputCachedImage(String imageId,Image image,float x,float y,float width,float height) throws IOException {
  String imageName=getImageName(imageId,image);
  out.print(imageName + "String_Node_Str");
  out.print(x + "String_Node_Str" + y+ "String_Node_Str");
  out.print(width + "String_Node_Str" + height+ "String_Node_Str");
  out.println("String_Node_Str");
}

Fixed version (ground truth):
private void outputCachedImage(String imageId,Image image,float x,float y,float width,float height) throws IOException {
  String imageName=getImageName(imageId,image);
  out.print(imageName + "String_Node_Str");
  out.print(x + "String_Node_Str" + y+ "String_Node_Str");
  out.println(width + "String_Node_Str" + height+ "String_Node_Str");
}
Program: 72460
Project: 72460
Buggy source:
private int outputImageSource(ImageSource imageSource,String prefix,String suffix){
  int originalWidth=imageSource.getWidth();
  int originalHeight=imageSource.getHeight();
  StringBuffer buffer=new StringBuffer();
  int count=0;
  for (int i=0; i < originalHeight; i++) {
    for (int j=0; j < originalWidth; j++) {
      int pixel=imageSource.getRGB(j,i);
      int alpha=(pixel >> 24) & 0xff;
      int red=(pixel >> 16) & 0xff;
      int green=(pixel >> 8) & 0xff;
      int blue=pixel & 0xff;
      red=transferColor(alpha,red);
      green=transferColor(alpha,green);
      blue=transferColor(alpha,blue);
      toBytes(buffer,red);
      toBytes(buffer,green);
      toBytes(buffer,blue);
      if (buffer.length() >= 250) {
        outputBuffer(buffer,prefix,suffix);
        ++count;
      }
    }
  }
  if (buffer.length() > 0) {
    outputBuffer(buffer,prefix,suffix);
    ++count;
  }
  return count;
}

Fixed version (ground truth):
private int outputImageSource(ArrayImageSource imageSource,String prefix,String suffix){
  int originalWidth=imageSource.getWidth();
  int originalHeight=imageSource.getHeight();
  StringBuffer buffer=new StringBuffer();
  int count=0;
  for (int i=0; i < originalHeight; i++) {
    for (int j=0; j < originalWidth; j++) {
      int pixel=imageSource.getRGB(j,i);
      int alpha=(pixel >> 24) & 0xff;
      int red=(pixel >> 16) & 0xff;
      int green=(pixel >> 8) & 0xff;
      int blue=pixel & 0xff;
      red=transferColor(alpha,red);
      green=transferColor(alpha,green);
      blue=transferColor(alpha,blue);
      toBytes(buffer,red);
      toBytes(buffer,green);
      toBytes(buffer,blue);
      if (buffer.length() >= 250) {
        outputBuffer(buffer,prefix,suffix);
        ++count;
      }
    }
  }
  if (buffer.length() > 0) {
    outputBuffer(buffer,prefix,suffix);
    ++count;
  }
  return count;
}
Program: 72461
Project: 72461
Buggy source:
/** 
 * Loads scripts that are stored in an external file. Used to support include-script. Each script file should be load only once. and the script in the file must be encoded in UTF-8.
 * @param fileName script file name
 */
public void loadScript(String fileName){
  ReportDesignHandle reportDesign=this.getDesign();
  URL url=null;
  if (reportDesign != null) {
    url=reportDesign.findResource(fileName,IResourceLocator.LIBRARY);
  }
  if (url == null) {
    return;
  }
  try {
    InputStream in=url.openStream();
    ByteArrayOutputStream out=new ByteArrayOutputStream();
    byte[] buffer=new byte[1024];
    int size=in.read(buffer);
    while (size != -1) {
      out.write(buffer,0,size);
      size=in.read(buffer);
    }
    byte[] script=out.toByteArray();
    ScriptExpression scriptExpr=new ScriptExpression(new String(script,"String_Node_Str"),fileName,1);
    execute(scriptExpr);
    in.close();
  }
 catch (  IOException ex) {
    log.log(Level.SEVERE,"String_Node_Str" + fileName + "String_Node_Str",ex);
    addException(new EngineException(MessageConstants.SCRIPT_FILE_LOAD_ERROR,url.toString(),ex));
  }
}

Fixed version (ground truth):
/** 
 * Loads scripts that are stored in an external file. Used to support include-script. Each script file should be load only once. and the script in the file must be encoded in UTF-8.
 * @param fileName script file name
 */
public void loadScript(String fileName){
  ReportDesignHandle reportDesign=this.getDesign();
  URL url=null;
  if (reportDesign != null) {
    url=reportDesign.findResource(fileName,IResourceLocator.LIBRARY);
  }
  if (url == null) {
    log.log(Level.SEVERE,"String_Node_Str" + fileName + "String_Node_Str");
    addException(new EngineException(MessageConstants.SCRIPT_FILE_LOAD_ERROR,fileName));
    return;
  }
  try {
    InputStream in=url.openStream();
    ByteArrayOutputStream out=new ByteArrayOutputStream();
    byte[] buffer=new byte[1024];
    int size=in.read(buffer);
    while (size != -1) {
      out.write(buffer,0,size);
      size=in.read(buffer);
    }
    byte[] script=out.toByteArray();
    ScriptExpression scriptExpr=new ScriptExpression(new String(script,"String_Node_Str"),fileName,1);
    execute(scriptExpr);
    in.close();
  }
 catch (  IOException ex) {
    log.log(Level.SEVERE,"String_Node_Str" + fileName + "String_Node_Str",ex);
    addException(new EngineException(MessageConstants.SCRIPT_FILE_LOAD_ERROR,url.toString(),ex));
  }
}
Program: 72462
Project: 72462
Buggy source:
protected void initialize(){
  createRoot();
  calculateSpecifiedWidth();
  offsetX=root.getContentX();
  offsetY=root.getContentY();
  if (specifiedWidth > 0) {
    root.setAllocatedWidth(specifiedWidth);
  }
 else {
    root.setAllocatedWidth(parent.getCurrentMaxContentWidth());
  }
  maxAvaWidth=root.getContentWidth();
  root.setAllocatedHeight(parent.getCurrentMaxContentHeight());
  maxAvaHeight=root.getContentHeight();
}

Fixed version (ground truth):
protected void initialize(){
  createRoot();
  validateBoxProperty(content,root.getStyle(),parent.getCurrentMaxContentWidth(),context.getMaxHeight());
  calculateSpecifiedWidth();
  offsetX=root.getContentX();
  offsetY=root.getContentY();
  if (specifiedWidth > 0) {
    root.setAllocatedWidth(specifiedWidth);
  }
 else {
    root.setAllocatedWidth(parent.getCurrentMaxContentWidth());
  }
  maxAvaWidth=root.getContentWidth();
  root.setAllocatedHeight(parent.getCurrentMaxContentHeight());
  maxAvaHeight=root.getContentHeight();
}
Program: 72463
Project: 72463
Buggy source:
protected void initialize(){
  createRoot();
  offsetX=root.getContentX();
  offsetY=root.getContentY();
  maxAvaWidth=root.getContentWidth();
  root.setAllocatedHeight(parent.getCurrentMaxContentHeight());
  maxAvaHeight=root.getContentHeight();
}

Fixed version (ground truth):
protected void initialize(){
  createRoot();
  validateBoxProperty(root.getStyle(),columnWidth,context.getMaxHeight());
  offsetX=root.getContentX();
  offsetY=root.getContentY();
  maxAvaWidth=root.getContentWidth();
  root.setAllocatedHeight(parent.getCurrentMaxContentHeight());
  maxAvaHeight=root.getContentHeight();
}
Program: 72465
Project: 72465
Buggy source:
/** 
 * Find a connection available for new statements in the pool, or create a new one if none available 
 */
private CacheConnection getAvailableConnection() throws DataException {
  Iterator it=this.getOdaConnections().iterator();
  while (it.hasNext()) {
    CacheConnection c=(CacheConnection)(it.next());
    if (c.currentStatements < c.maxStatements)     return c;
  }
  return newConnection();
}

Fixed version (ground truth):
/** 
 * Find a connection available for new statements in the pool, or create a new one if none available 
 */
private CacheConnection getAvailableConnection() throws DataException {
  Iterator it=this.getOdaConnections(true).iterator();
  while (it.hasNext()) {
    CacheConnection c=(CacheConnection)(it.next());
    if (c.currentStatements < c.maxStatements)     return c;
  }
  return newConnection();
}
Program: 72466
Project: 72466
Buggy source:
private Set<CacheConnection> getOdaConnections(){
  if (DataSource.dataEngineLevelConnectionPool.get(this.session) == null) {
    DataSource.dataEngineLevelConnectionPool.put(this.session,new HashMap<ConnectionProp,Set<CacheConnection>>());
  }
  Map<ConnectionProp,Set<CacheConnection>> odaConnectionsMap=DataSource.dataEngineLevelConnectionPool.get(this.session);
  ConnectionProp connProp=new ConnectionProp(this.driverName,this.connectionProps,this.appContext);
  if (odaConnectionsMap.get(connProp) == null) {
    odaConnectionsMap.put(connProp,new HashSet<CacheConnection>());
  }
  return odaConnectionsMap.get(connProp);
}

Fixed version (ground truth):
private Set<CacheConnection> getOdaConnections(boolean populateToCache){
  if (DataSource.dataEngineLevelConnectionPool.get(this.session) == null) {
    if (populateToCache) {
      DataSource.dataEngineLevelConnectionPool.put(this.session,new HashMap<ConnectionProp,Set<CacheConnection>>());
    }
 else {
      return new HashSet<CacheConnection>();
    }
  }
  Map<ConnectionProp,Set<CacheConnection>> odaConnectionsMap=DataSource.dataEngineLevelConnectionPool.get(this.session);
  ConnectionProp connProp=new ConnectionProp(this.driverName,this.connectionProps,this.appContext);
  if (odaConnectionsMap.get(connProp) == null) {
    odaConnectionsMap.put(connProp,new HashSet<CacheConnection>());
  }
  return odaConnectionsMap.get(connProp);
}
Program: 72467
Project: 72467
Buggy source:
public boolean isOpen(){
  return this.getOdaConnections().size() > 0;
}

Fixed version (ground truth):
public boolean isOpen(){
  return this.getOdaConnections(false).size() > 0;
}
Program: 72468
Project: 72468
Buggy source:
/** 
 * Opens a new Connection and add it to the pool
 * @return
 * @throws DataException
 */
private CacheConnection newConnection() throws DataException {
  CacheConnection conn=new CacheConnection();
  conn.odaConn=ConnectionManager.getInstance().openConnection(driverName,connectionProps,appContext);
  int max=conn.odaConn.getMaxQueries();
  if (max != 0)   conn.maxStatements=max;
  this.getOdaConnections().add(conn);
  return conn;
}

Fixed version (ground truth):
/** 
 * Opens a new Connection and add it to the pool
 * @return
 * @throws DataException
 */
private CacheConnection newConnection() throws DataException {
  CacheConnection conn=new CacheConnection();
  conn.odaConn=ConnectionManager.getInstance().openConnection(driverName,connectionProps,appContext);
  int max=conn.odaConn.getMaxQueries();
  if (max != 0)   conn.maxStatements=max;
  this.getOdaConnections(true).add(conn);
  return conn;
}
Program: 72469
Project: 72469
Buggy source:
public void close(){
  if (statementMap.size() > 0) {
    Iterator keySet=statementMap.keySet().iterator();
    while (keySet.hasNext()) {
      PreparedStatement stmt=(PreparedStatement)keySet.next();
      try {
        stmt.close();
      }
 catch (      DataException e) {
        logger.logp(Level.FINE,className,"String_Node_Str","String_Node_Str",e);
      }
    }
    statementMap.clear();
  }
  Set<CacheConnection> it=this.getOdaConnections();
  if (it.size() > 1) {
    CacheConnection conn=it.iterator().next();
    conn.currentStatements=0;
    it.remove(conn);
    for (    CacheConnection connections : it) {
      try {
        connections.odaConn.close();
      }
 catch (      DataException e) {
        e.printStackTrace();
      }
    }
    it.clear();
    it.add(conn);
  }
}

Fixed version (ground truth):
public void close(){
  if (statementMap.size() > 0) {
    Iterator keySet=statementMap.keySet().iterator();
    while (keySet.hasNext()) {
      PreparedStatement stmt=(PreparedStatement)keySet.next();
      try {
        stmt.close();
      }
 catch (      DataException e) {
        logger.logp(Level.FINE,className,"String_Node_Str","String_Node_Str",e);
      }
    }
    statementMap.clear();
  }
  Set<CacheConnection> it=this.getOdaConnections(false);
  if (it.size() > 1) {
    CacheConnection conn=it.iterator().next();
    conn.currentStatements=0;
    it.remove(conn);
    for (    CacheConnection connections : it) {
      try {
        connections.odaConn.close();
      }
 catch (      DataException e) {
        e.printStackTrace();
      }
    }
    it.clear();
    it.add(conn);
  }
}
Program: 72470
Project: 72470
Buggy source:
public IStyle getComputedStyle(){
  if (computedStyle == null) {
    CSSEngine cssEngine=null;
    if (report != null) {
      assert(report instanceof ReportContent);
      cssEngine=((ReportContent)report).getCSSEngine();
    }
    if (cssEngine == null) {
      cssEngine=new BIRTCSSEngine();
    }
    computedStyle=new ComputedStyle(this);
  }
  return computedStyle;
}

Fixed version (ground truth):
public IStyle getComputedStyle(){
  if (computedStyle == null) {
    if (parent == null) {
      computedStyle=new ComputedStyle(this);
    }
 else {
      if (inlineStyle == null || inlineStyle.isEmpty()) {
        ComputedStyle pcs=(ComputedStyle)((IContent)parent).getComputedStyle();
        ComputedStyle cs=pcs.getCachedStyle(styleClass);
        if (cs == null) {
          cs=new ComputedStyle(this);
          pcs.addCachedStyle(styleClass,cs);
        }
        computedStyle=cs;
      }
 else {
        computedStyle=new ComputedStyle(this);
      }
    }
  }
  return computedStyle;
}
Program: 72471
Project: 72471
Buggy source:
public IStyle getComputedStyle(){
  if (computedStyle == null) {
    computedStyle=new CellComputedStyle(this);
  }
  return computedStyle;
}

Fixed version (ground truth):
public IStyle getComputedStyle(){
  if (computedStyle == null) {
    if (inlineStyle == null || inlineStyle.isEmpty()) {
      String cacheKey=styleClass;
      ITableContent table=((IRowContent)parent).getTable();
      if (column >= 0 && column < table.getColumnCount()) {
        IColumn tblColumn=table.getColumn(column);
        if (tblColumn != null) {
          String columnStyleClass=tblColumn.getStyleClass();
          if (columnStyleClass != null) {
            cacheKey=cacheKey + columnStyleClass;
          }
        }
      }
      ComputedStyle pcs=(ComputedStyle)((IContent)parent).getComputedStyle();
      ComputedStyle cs=pcs.getCachedStyle(cacheKey);
      if (cs == null) {
        cs=new CellComputedStyle(this);
        pcs.addCachedStyle(styleClass,cs);
      }
      computedStyle=cs;
    }
 else {
      computedStyle=new CellComputedStyle(this);
    }
  }
  return computedStyle;
}
Program: 72472
Project: 72472
Buggy source:
public CSSValue getProperty(int index){
  if (values[index] != null) {
    return values[index];
  }
  if (parent != null) {
    return parent.getProperty(index);
  }
  return null;
}

Fixed version (ground truth):
public CSSValue getProperty(int index){
  if (!resolveFlags[index]) {
    if (parent != null) {
      values[index]=parent.getProperty(index);
    }
    resolveFlags[index]=true;
  }
  return values[index];
}
Program: 72473
Project: 72473
Buggy source:
public void setProperty(int index,CSSValue value){
  values[index]=value;
}

Fixed version (ground truth):
public void setProperty(int index,CSSValue value){
  values[index]=value;
  resolveFlags[index]=true;
}
Program: 72474
Project: 72474
Buggy source:
public IReportRunnable getReportRunnable(){
  loadMainInfoLazily();
  return getReportRunnable(true,systemId);
}

Fixed version (ground truth):
public synchronized IReportRunnable getReportRunnable(){
  loadMainInfoLazily();
  if (reportRunnable == null) {
    reportRunnable=getReportRunnable(true,systemId);
  }
  return reportRunnable.cloneRunnable();
}
Program: 72475
Project: 72475
Buggy source:
private ClassLoader getClassLoader(String systemId){
  if (applicationClassLoader == null) {
    applicationClassLoader=new ApplicationClassLoader(engine,getReportRunnable(false,systemId));
  }
  return applicationClassLoader;
}

Fixed version (ground truth):
public synchronized ClassLoader getClassLoader(){
  if (applicationClassLoader == null) {
    loadMainInfoLazily();
    applicationClassLoader=createClassLoader(systemId);
  }
  return applicationClassLoader;
}
Program: 72476
Project: 72476
Buggy source:
private void loadBasicInfoV0(DataInputStream di,ReportDocumentCoreInfo documentInfo) throws IOException {
  documentInfo.checkpoint=CHECKPOINT_INIT;
  documentInfo.pageCount=PAGECOUNT_INIT;
  documentInfo.checkpoint=IOUtil.readInt(di);
  documentInfo.pageCount=IOUtil.readLong(di);
  if (isLoaded && documentInfo.checkpoint == checkpoint) {
    return;
  }
  String orgSystemId=IOUtil.readString(di);
  if (systemId == null) {
    documentInfo.systemId=orgSystemId;
  }
 else {
    documentInfo.systemId=systemId;
  }
}

Fixed version (ground truth):
private void loadBasicInfoV0(DataInputStream di,ReportDocumentCoreInfo documentInfo) throws IOException {
  documentInfo.checkpoint=CHECKPOINT_INIT;
  documentInfo.pageCount=PAGECOUNT_INIT;
  documentInfo.checkpoint=IOUtil.readInt(di);
  documentInfo.pageCount=IOUtil.readLong(di);
  if (isLoaded && documentInfo.checkpoint == checkpoint) {
    return;
  }
  String orgSystemId=IOUtil.readString(di);
  if (systemId == null) {
    systemId=orgSystemId;
  }
}
Program: 72477
Project: 72477
Buggy source:
private void loadOldBasicInfo(DataInputStream coreStream,ReportDocumentCoreInfo documentInfo) throws IOException {
  documentInfo.checkpoint=CHECKPOINT_INIT;
  documentInfo.pageCount=PAGECOUNT_INIT;
  if (!archive.exists(CHECKPOINT_STREAM)) {
    documentInfo.checkpoint=CHECKPOINT_END;
    initializePageHintReader();
    if (pageHintReader != null) {
      documentInfo.pageCount=pageHintReader.getTotalPage();
    }
  }
 else {
    RAInputStream in=archive.getStream(CHECKPOINT_STREAM);
    try {
      DataInputStream di=new DataInputStream(in);
      documentInfo.checkpoint=IOUtil.readInt(di);
      documentInfo.pageCount=IOUtil.readLong(di);
    }
  finally {
      if (in != null) {
        in.close();
      }
    }
    if (documentInfo.checkpoint == checkpoint) {
      return;
    }
  }
  String orgSystemId=IOUtil.readString(coreStream);
  if (systemId == null) {
    documentInfo.systemId=orgSystemId;
  }
 else {
    documentInfo.systemId=systemId;
  }
}

Fixed version (ground truth):
private void loadOldBasicInfo(DataInputStream coreStream,ReportDocumentCoreInfo documentInfo) throws IOException {
  documentInfo.checkpoint=CHECKPOINT_INIT;
  documentInfo.pageCount=PAGECOUNT_INIT;
  if (!archive.exists(CHECKPOINT_STREAM)) {
    documentInfo.checkpoint=CHECKPOINT_END;
    initializePageHintReader();
    if (pageHintReader != null) {
      documentInfo.pageCount=pageHintReader.getTotalPage();
    }
  }
 else {
    RAInputStream in=archive.getStream(CHECKPOINT_STREAM);
    try {
      DataInputStream di=new DataInputStream(in);
      documentInfo.checkpoint=IOUtil.readInt(di);
      documentInfo.pageCount=IOUtil.readLong(di);
    }
  finally {
      if (in != null) {
        in.close();
      }
    }
    if (documentInfo.checkpoint == checkpoint) {
      return;
    }
  }
  String orgSystemId=IOUtil.readString(coreStream);
  if (systemId == null) {
    systemId=orgSystemId;
  }
}
Program: 72478
Project: 72478
Buggy source:
protected void doRefreshV0(DataInputStream di) throws IOException {
  ReportDocumentCoreInfo documentInfo=new ReportDocumentCoreInfo();
  loadBasicInfoV0(di,documentInfo);
  if (isLoaded && documentInfo.checkpoint == checkpoint) {
    return;
  }
  loadMainInfo(di,documentInfo);
  checkpoint=documentInfo.checkpoint;
  pageCount=documentInfo.pageCount;
  systemId=documentInfo.systemId;
  globalVariables=documentInfo.globalVariables;
  parameters=documentInfo.parameters;
  applicationClassLoader=documentInfo.applicationClassLoader;
  if (documentInfo.checkpoint == CHECKPOINT_END) {
    bookmarks=readMap(di);
    tocTree=new TOCTree();
    TOCBuilder.read(tocTree,di,applicationClassLoader);
    reportletsIndexById=readMap(di);
    reportletsIndexByBookmark=readMap(di);
  }
}

Fixed version (ground truth):
protected void doRefreshV0(DataInputStream di) throws IOException {
  ReportDocumentCoreInfo documentInfo=new ReportDocumentCoreInfo();
  loadBasicInfoV0(di,documentInfo);
  if (isLoaded && documentInfo.checkpoint == checkpoint) {
    return;
  }
  loadMainInfo(di,documentInfo);
  checkpoint=documentInfo.checkpoint;
  pageCount=documentInfo.pageCount;
  globalVariables=documentInfo.globalVariables;
  parameters=documentInfo.parameters;
  if (documentInfo.checkpoint == CHECKPOINT_END) {
    bookmarks=readMap(di);
    tocTree=new TOCTree();
    TOCBuilder.read(tocTree,di,applicationClassLoader);
    reportletsIndexById=readMap(di);
    reportletsIndexByBookmark=readMap(di);
  }
}
Program: 72479
Project: 72479
Buggy source:
public ITOCTree getTOCTree(String format,ULocale locale,TimeZone timeZone){
  if (!isComplete()) {
    return null;
  }
  intializeTOC();
  TOCTree result=new TOCTree(tocTree.getTOCRoot(),format,locale,timeZone,((ReportRunnable)getReportRunnable()).getReport());
  return result;
}

Fixed version (ground truth):
public ITOCTree getTOCTree(String format,ULocale locale,TimeZone timeZone){
  if (!isComplete()) {
    return null;
  }
  intializeTOC();
  TOCTree result=new TOCTree(tocTree.getTOCRoot(),format,locale,timeZone,((ReportRunnable)getOnPreparedRunnable()).getReport());
  return result;
}
Program: 72480
Project: 72480
Buggy source:
protected void doOldRefresh(DataInputStream coreStream) throws IOException {
  ReportDocumentCoreInfo documentInfo=new ReportDocumentCoreInfo();
  loadOldBasicInfo(coreStream,documentInfo);
  if (documentInfo.checkpoint == CHECKPOINT_INIT) {
    return;
  }
  loadMainInfo(coreStream,documentInfo);
  checkpoint=documentInfo.checkpoint;
  pageCount=documentInfo.pageCount;
  systemId=documentInfo.systemId;
  globalVariables=documentInfo.globalVariables;
  parameters=documentInfo.parameters;
  applicationClassLoader=documentInfo.applicationClassLoader;
}

Fixed version (ground truth):
protected void doOldRefresh(DataInputStream coreStream) throws IOException {
  ReportDocumentCoreInfo documentInfo=new ReportDocumentCoreInfo();
  loadOldBasicInfo(coreStream,documentInfo);
  if (documentInfo.checkpoint == CHECKPOINT_INIT) {
    return;
  }
  loadMainInfo(coreStream,documentInfo);
  checkpoint=documentInfo.checkpoint;
  pageCount=documentInfo.pageCount;
  globalVariables=documentInfo.globalVariables;
  parameters=documentInfo.parameters;
}
Program: 72481
Project: 72481
Buggy source:
private void loadMainInfo(DataInputStream coreStream,ReportDocumentCoreInfo documentInfo) throws IOException {
  documentInfo.applicationClassLoader=getClassLoader(documentInfo.systemId);
  Map originalParameters=IOUtil.readMap(coreStream,documentInfo.applicationClassLoader);
  documentInfo.parameters=convertToCompatibleParameter(originalParameters);
  documentInfo.globalVariables=(HashMap)IOUtil.readMap(coreStream,documentInfo.applicationClassLoader);
}

Fixed version (ground truth):
private void loadMainInfo(DataInputStream coreStream,ReportDocumentCoreInfo documentInfo) throws IOException {
  if (applicationClassLoader == null) {
    applicationClassLoader=createClassLoader(systemId);
  }
  Map originalParameters=IOUtil.readMap(coreStream,applicationClassLoader);
  documentInfo.parameters=convertToCompatibleParameter(originalParameters);
  documentInfo.globalVariables=(HashMap)IOUtil.readMap(coreStream,applicationClassLoader);
}
Program: 72482
Project: 72482
Buggy source:
/** 
 * @param dataType
 * @return
 */
public static ICalculator getCalculator(Class<?> clz){
  if (clz.equals(Boolean.class)) {
    return new BooleanCalculator();
  }
 else   if (clz.equals(Date.class)) {
    return new DateCalculator();
  }
 else   if (clz.equals(String.class)) {
    return new StringCalculator();
  }
 else   if (clz.equals(BigDecimal.class)) {
    return new BigDecimalCalculator();
  }
 else {
    return new NumberCalculator();
  }
}

Fixed version (ground truth):
/** 
 * @param dataType
 * @return
 */
public static ICalculator getCalculator(Class<?> clz){
  if (clz.equals(Boolean.class)) {
    return new BooleanCalculator();
  }
 else   if (Date.class.isAssignableFrom(clz)) {
    return new DateCalculator();
  }
 else   if (clz.equals(String.class)) {
    return new StringCalculator();
  }
 else   if (clz.equals(BigDecimal.class)) {
    return new BigDecimalCalculator();
  }
 else {
    return new NumberCalculator();
  }
}
Program: 72483
Project: 72483
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+=letterSpacing * textLength;
  if (textArea.hasSpace(wordWidth)) {
    addWord(textArea,textLength,wordWidth);
    if (remainWords.hasWord()) {
      if (textArea.hasSpace(wordSpacing)) {
        textArea.addWordSpacing(wordSpacing);
      }
 else {
        textArea.setLineBreak(true);
        hasLineBreak=true;
      }
    }
  }
 else {
    if (isNewLine && textArea.isEmpty()) {
      if (hyphenation) {
        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+=letterSpacing * textLength;
  if (textArea.hasSpace(wordWidth)) {
    addWord(textArea,textLength,wordWidth);
    wordVestige=null;
    if (remainWords.hasWord()) {
      if (textArea.hasSpace(wordSpacing)) {
        textArea.addWordSpacing(wordSpacing);
      }
 else {
        textArea.setLineBreak(true);
        hasLineBreak=true;
      }
    }
  }
 else {
    if (isNewLine && textArea.isEmpty()) {
      if (hyphenation) {
        doHyphenation(word.getValue(),textArea);
      }
 else {
        addWord(textArea,textLength,wordWidth);
      }
    }
 else {
      wordVestige=null;
      remainWord=word;
    }
    textArea.setLineBreak(true);
    hasLineBreak=true;
  }
}
Program: 72484
Project: 72484
Buggy source:
private void addWordVestige(TextArea area,int textLength,int wordWidth,String vestigeString){
  addWord(area,textLength,wordWidth);
  if (vestigeString.length() == 0) {
    wordVestige=null;
  }
 else {
    wordVestige=new Word(vestigeString,0,vestigeString.length());
  }
  return;
}

Fixed version (ground truth):
private void addWordVestige(TextArea area,int vestigeTextLength,int vestigeWordWidth,String vestigeString){
  addWord(area,vestigeTextLength,vestigeWordWidth);
  if (vestigeString.length() == 0) {
    wordVestige=null;
  }
 else {
    wordVestige=new Word(vestigeString,0,vestigeString.length());
  }
}
Program: 72485
Project: 72485
Buggy source:
synchronized public boolean removeEntry(String name) throws IOException {
  if (isArchiveFileAvailable(af)) {
    return af.removeEntry(name);
  }
 else {
    throw new IOException("String_Node_Str" + af.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
synchronized public boolean removeEntry(String name) throws IOException {
  if (isArchiveFileAvailable(af)) {
    return af.removeEntry(name);
  }
 else {
    throw new IOException("String_Node_Str" + name + "String_Node_Str"+ systemId);
  }
}
Program: 72486
Project: 72486
Buggy source:
/** 
 * save the file. If the file is transient file, after saving, it will be converts to normal file.
 * @throws IOException
 */
public void save() throws IOException {
  if (isArchiveFileAvailable(af)) {
    if (af instanceof ArchiveFileV2) {
      ((ArchiveFileV2)af).save();
    }
 else {
      af.flush();
    }
  }
 else {
    throw new IOException("String_Node_Str" + af.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * save the file. If the file is transient file, after saving, it will be converts to normal file.
 * @throws IOException
 */
public void save() throws IOException {
  if (isArchiveFileAvailable(af)) {
    if (af instanceof ArchiveFileV2) {
      ((ArchiveFileV2)af).save();
    }
 else {
      af.flush();
    }
  }
 else {
    throw new IOException("String_Node_Str" + systemId);
  }
}
Program: 72487
Project: 72487
Buggy source:
synchronized public void flush() throws IOException {
  if (isArchiveFileAvailable(af)) {
    af.flush();
  }
 else {
    throw new IOException("String_Node_Str" + af.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
synchronized public void flush() throws IOException {
  if (isArchiveFileAvailable(af)) {
    af.flush();
  }
 else {
    throw new IOException("String_Node_Str" + systemId);
  }
}
Program: 72488
Project: 72488
Buggy source:
synchronized public ArchiveEntry getEntry(String name) throws IOException {
  if (isArchiveFileAvailable(af)) {
    return af.getEntry(name);
  }
 else {
    throw new IOException("String_Node_Str" + af.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
synchronized public ArchiveEntry getEntry(String name) throws IOException {
  if (isArchiveFileAvailable(af)) {
    return af.getEntry(name);
  }
 else {
    throw new IOException("String_Node_Str" + name + "String_Node_Str"+ systemId);
  }
}
Program: 72489
Project: 72489
Buggy source:
synchronized public void refresh() throws IOException {
  if (isArchiveFileAvailable(af)) {
    af.refresh();
  }
 else {
    throw new IOException("String_Node_Str" + af.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
synchronized public void refresh() throws IOException {
  if (isArchiveFileAvailable(af)) {
    af.refresh();
  }
 else {
    throw new IOException("String_Node_Str" + systemId);
  }
}
Program: 72490
Project: 72490
Buggy source:
synchronized public ArchiveEntry createEntry(String name) throws IOException {
  if (isArchiveFileAvailable(af)) {
    return af.createEntry(name);
  }
 else {
    throw new IOException("String_Node_Str" + af.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
synchronized public ArchiveEntry createEntry(String name) throws IOException {
  if (isArchiveFileAvailable(af)) {
    return af.createEntry(name);
  }
 else {
    throw new IOException("String_Node_Str" + name + "String_Node_Str"+ systemId);
  }
}
Program: 72491
Project: 72491
Buggy source:
public void unlockEntry(Object locker) throws IOException {
  if (isArchiveFileAvailable(af)) {
    af.unlockEntry(locker);
  }
 else {
    throw new IOException("String_Node_Str" + af.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
public void unlockEntry(Object locker) throws IOException {
  if (isArchiveFileAvailable(af)) {
    af.unlockEntry(locker);
  }
 else {
    throw new IOException("String_Node_Str" + systemId);
  }
}
Program: 72492
Project: 72492
Buggy source:
private void assertWritable() throws IOException {
  assertOpen();
  if (!isWritable) {
    throw new IOException("String_Node_Str");
  }
}

Fixed version (ground truth):
private void assertWritable() throws IOException {
  assertOpen();
  if (!isWritable) {
    throw new IOException("String_Node_Str" + systemId);
  }
}
Program: 72493
Project: 72493
Buggy source:
private void assertOpen() throws IOException {
  if (isClosed) {
    throw new IOException("String_Node_Str");
  }
}

Fixed version (ground truth):
private void assertOpen() throws IOException {
  if (isClosed) {
    throw new IOException("String_Node_Str" + systemId);
  }
}
Program: 72494
Project: 72494
Buggy source:
/** 
 * Convert String without specified locale to java.util.Date Try to format the given String for JRE default Locale, if it fails, try to format the String for Locale.US 
 * @param source the String to be convert
 * @param locate the locate of the string
 * @return result Date
 */
private static Date toDate(String source) throws BirtException {
  try {
    return toDateISO8601(source);
  }
 catch (  BirtException e) {
    try {
      return toDate(source,ULocale.getDefault());
    }
 catch (    BirtException use) {
      return toDate(source,DEFAULT_LOCALE);
    }
  }
}

Fixed version (ground truth):
/** 
 * Convert String without specified locale to java.util.Date Try to format the given String for JRE default Locale, if it fails, try to format the String for Locale.US 
 * @param source the String to be convert
 * @param locate the locate of the string
 * @return result Date
 */
private static Date toDate(String source) throws BirtException {
  try {
    return toDateISO8601(source);
  }
 catch (  BirtException e) {
    try {
      return toDate(source,JRE_DEFAULT_LOCALE);
    }
 catch (    BirtException use) {
      return toDate(source,DEFAULT_LOCALE);
    }
  }
}
Program: 72496
Project: 72496
Buggy source:
/** 
 * Boolean -> Integer true 	-> 1 others 	-> 0  Date -> Integer Date.getTime(); String -> Integer Integer.valueOf();
 * @param source
 * @return
 * @throws BirtException
 */
public static Integer toInteger(Object source) throws BirtException {
  if (source == null)   return null;
  if (source instanceof Integer) {
    return (Integer)source;
  }
 else   if (source instanceof Number) {
    int intValue=((Number)source).intValue();
    return new Integer(intValue);
  }
 else   if (source instanceof Boolean) {
    if (true == ((Boolean)source).booleanValue())     return new Integer(1);
    return new Integer(0);
  }
 else   if (source instanceof Date) {
    long longValue=((Date)source).getTime();
    return new Integer((int)longValue);
  }
 else   if (source instanceof String) {
    try {
      return new Integer(Double.valueOf((String)source).intValue());
    }
 catch (    NumberFormatException e) {
      try {
        Number number=NumberFormat.getInstance(ULocale.getDefault()).parse((String)source);
        if (number != null)         return new Integer(number.intValue());
        throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
      }
 catch (      ParseException e1) {
        throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
      }
    }
  }
 else {
    throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
  }
}

Fixed version (ground truth):
/** 
 * Boolean -> Integer true 	-> 1 others 	-> 0  Date -> Integer Date.getTime(); String -> Integer Integer.valueOf();
 * @param source
 * @return
 * @throws BirtException
 */
public static Integer toInteger(Object source) throws BirtException {
  if (source == null)   return null;
  if (source instanceof Integer) {
    return (Integer)source;
  }
 else   if (source instanceof Number) {
    int intValue=((Number)source).intValue();
    return new Integer(intValue);
  }
 else   if (source instanceof Boolean) {
    if (true == ((Boolean)source).booleanValue())     return new Integer(1);
    return new Integer(0);
  }
 else   if (source instanceof Date) {
    long longValue=((Date)source).getTime();
    return new Integer((int)longValue);
  }
 else   if (source instanceof String) {
    try {
      return new Integer(Double.valueOf((String)source).intValue());
    }
 catch (    NumberFormatException e) {
      try {
        Number number=NumberFormat.getInstance(JRE_DEFAULT_LOCALE).parse((String)source);
        if (number != null)         return new Integer(number.intValue());
        throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
      }
 catch (      ParseException e1) {
        throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
      }
    }
  }
 else {
    throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
  }
}
Program: 72497
Project: 72497
Buggy source:
/** 
 * Boolean -> Double true 	-> 1 others 	-> 0  Date -> Double Date.getTime(); String -> Double Double.valueOf(String);
 * @param source
 * @return
 * @throws BirtException
 */
public static Double toDouble(Object source) throws BirtException {
  if (source == null)   return null;
  if (source instanceof Double) {
    return (Double)source;
  }
 else   if (source instanceof Number) {
    double doubleValue=((Number)source).doubleValue();
    return new Double(doubleValue);
  }
 else   if (source instanceof Boolean) {
    if (true == ((Boolean)source).booleanValue())     return new Double(1d);
    return new Double(0d);
  }
 else   if (source instanceof Date) {
    double doubleValue=((Date)source).getTime();
    return new Double(doubleValue);
  }
 else   if (source instanceof String) {
    try {
      return Double.valueOf((String)source);
    }
 catch (    NumberFormatException e) {
      try {
        Number number=NumberFormat.getInstance(ULocale.getDefault()).parse((String)source);
        if (number != null)         return new Double(number.doubleValue());
        throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
      }
 catch (      ParseException e1) {
        throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
      }
    }
  }
 else {
    throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
  }
}

Fixed version (ground truth):
/** 
 * Boolean -> Double true 	-> 1 others 	-> 0  Date -> Double Date.getTime(); String -> Double Double.valueOf(String);
 * @param source
 * @return
 * @throws BirtException
 */
public static Double toDouble(Object source) throws BirtException {
  if (source == null)   return null;
  if (source instanceof Double) {
    return (Double)source;
  }
 else   if (source instanceof Number) {
    double doubleValue=((Number)source).doubleValue();
    return new Double(doubleValue);
  }
 else   if (source instanceof Boolean) {
    if (true == ((Boolean)source).booleanValue())     return new Double(1d);
    return new Double(0d);
  }
 else   if (source instanceof Date) {
    double doubleValue=((Date)source).getTime();
    return new Double(doubleValue);
  }
 else   if (source instanceof String) {
    try {
      return Double.valueOf((String)source);
    }
 catch (    NumberFormatException e) {
      try {
        Number number=NumberFormat.getInstance(JRE_DEFAULT_LOCALE).parse((String)source);
        if (number != null)         return new Double(number.doubleValue());
        throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
      }
 catch (      ParseException e1) {
        throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
      }
    }
  }
 else {
    throw new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"});
  }
}
Program: 72498
Project: 72498
Buggy source:
/** 
 * @param source
 * @return
 */
private Double toDouble(String source) throws DataException {
  try {
    return Double.valueOf((String)source);
  }
 catch (  NumberFormatException e) {
    try {
      Number number=NumberFormat.getInstance(ULocale.getDefault()).parse((String)source);
      if (number != null)       return new Double(number.doubleValue());
      throw DataException.wrap(new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"}));
    }
 catch (    ParseException e1) {
      throw DataException.wrap(new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"}));
    }
  }
}

Fixed version (ground truth):
/** 
 * @param source
 * @return
 */
private Double toDouble(String source) throws DataException {
  try {
    return Double.valueOf((String)source);
  }
 catch (  NumberFormatException e) {
    try {
      Number number=NumberFormat.getInstance(locale).parse((String)source);
      if (number != null)       return new Double(number.doubleValue());
      throw DataException.wrap(new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"}));
    }
 catch (    ParseException e1) {
      throw DataException.wrap(new CoreException(ResourceConstants.CONVERT_FAILS,new Object[]{source.toString(),"String_Node_Str"}));
    }
  }
}
Program: 72500
Project: 72500
Buggy source:
public int getContentX(){
  return PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_BORDER_LEFT_WIDTH)) + PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_PADDING_LEFT));
}

Fixed version (ground truth):
public int getContentX(){
  return PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_BORDER_LEFT_WIDTH),width) + PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_PADDING_LEFT),width);
}
Program: 72501
Project: 72501
Buggy source:
public int getContentY(){
  return PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_BORDER_TOP_WIDTH)) + PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_PADDING_TOP));
}

Fixed version (ground truth):
public int getContentY(){
  return PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_BORDER_TOP_WIDTH),width) + PropertyUtil.getDimensionValue(style.getProperty(IStyle.STYLE_PADDING_TOP),width);
}
Program: 72502
Project: 72502
Buggy source:
/** 
 * Checks if a text is in a table header/footer or group header/footer.
 * @param text
 * @return
 */
private boolean isInHeaderFooter(ITextContent text,HashMap map){
  Object generateBy=text.getGenerateBy();
  IElement parent=text.getParent();
  while (parent != null) {
    if (parent instanceof IContent) {
      IContent content=(IContent)parent;
      ReportItemDesign design=(ReportItemDesign)content.getGenerateBy();
      if (design != null && design.getQuery() != null) {
        map.put(generateBy,Boolean.FALSE);
        return false;
      }
    }
    if (parent instanceof IBandContent) {
      IBandContent bandContent=(IBandContent)parent;
      int bandType=bandContent.getBandType();
      if (bandType == IBandContent.BAND_HEADER || bandType == IBandContent.BAND_FOOTER || bandType == IBandContent.BAND_GROUP_HEADER || bandType == IBandContent.BAND_GROUP_FOOTER) {
        IElement bandParent=bandContent.getParent();
        while (bandParent instanceof IGroupContent) {
          bandParent=bandParent.getParent();
        }
        if (bandParent instanceof ITableContent) {
          map.put(generateBy,Boolean.TRUE);
          return true;
        }
      }
    }
    parent=parent.getParent();
  }
  map.put(generateBy,Boolean.FALSE);
  return false;
}

Fixed version (ground truth):
/** 
 * Checks if a text is in a table header/footer or group header/footer.
 * @param text
 * @return
 */
private boolean isInHeaderFooter(ITextContent text,HashMap map){
  Object generateBy=text.getGenerateBy();
  IElement parent=text.getParent();
  while (parent != null) {
    if (parent instanceof IContent) {
      IContent content=(IContent)parent;
      Object parentGenerateBy=content.getGenerateBy();
      if (parentGenerateBy instanceof ReportItemDesign) {
        ReportItemDesign design=(ReportItemDesign)parentGenerateBy;
        if (design.getQuery() != null) {
          map.put(generateBy,Boolean.FALSE);
          return false;
        }
      }
 else       if (null != parentGenerateBy) {
        map.put(generateBy,Boolean.FALSE);
        return false;
      }
    }
    if (parent instanceof IBandContent) {
      IBandContent bandContent=(IBandContent)parent;
      int bandType=bandContent.getBandType();
      if (bandType == IBandContent.BAND_HEADER || bandType == IBandContent.BAND_FOOTER || bandType == IBandContent.BAND_GROUP_HEADER || bandType == IBandContent.BAND_GROUP_FOOTER) {
        IElement bandParent=bandContent.getParent();
        while (bandParent instanceof IGroupContent) {
          bandParent=bandParent.getParent();
        }
        if (bandParent instanceof ITableContent) {
          map.put(generateBy,Boolean.TRUE);
          return true;
        }
      }
    }
    parent=parent.getParent();
  }
  map.put(generateBy,Boolean.FALSE);
  return false;
}
Program: 72503
Project: 72503
Buggy source:
private void doHyphenation(String str,TextArea area){
  IHyphenationManager hm=new DefaultHyphenationManager();
  Hyphenation hyph=hm.getHyphenation(str);
  FontInfo fi=area.getFontInfo();
  int endHyphenIndex=hyphen(0,area.getMaxWidth() - area.getWidth(),hyph,fi);
  if (endHyphenIndex == 0 && area.getWidth() == 0 && area.getMaxWidth() == 0) {
    addWord(area,1,getTextWidth(fi,hyph.getHyphenText(0,1)));
    wordVestige=new Word(str,1,str.length());
  }
 else {
    addWord(area,endHyphenIndex,getTextWidth(fi,hyph.getHyphenText(0,endHyphenIndex)));
    wordVestige=new Word(str,endHyphenIndex,str.length());
  }
}

Fixed version (ground truth):
private void doHyphenation(String str,TextArea area){
  IHyphenationManager hm=new DefaultHyphenationManager();
  Hyphenation hyph=hm.getHyphenation(str);
  FontInfo fi=area.getFontInfo();
  int endHyphenIndex=hyphen(0,area.getMaxWidth() - area.getWidth(),hyph,fi);
  if (endHyphenIndex == 0 && area.getWidth() == 0 && area.getMaxWidth() == 0) {
    addWord(area,1,getTextWidth(fi,hyph.getHyphenText(0,1)));
    wordVestige=new Word(str,1,str.length());
  }
 else {
    addWord(area,endHyphenIndex,getTextWidth(fi,hyph.getHyphenText(0,endHyphenIndex)) + letterSpacing * (endHyphenIndex - 1));
    wordVestige=new Word(str,endHyphenIndex,str.length());
  }
}
Program: 72504
Project: 72504
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();
  System.out.print(textArea.getText());
  System.out.print("String_Node_Str" + offset + "String_Node_Str");
  return textArea;
}