Program: 45362
Project: 45362
Buggy source:
/** 
 * Check out this error, if it says table not found, create a new table.
 * @param ex error thrown.
 * @return true if file was not found and was successfully created.
 * @exception DBException Converts and returns SQLExceptions, or if no rows updated, throws INVALID_RECORD.
 */
public boolean createIfNotFoundError(DBException ex) throws DBException {
  if (ex.getErrorCode() == DBConstants.FILE_NOT_FOUND)   if (this.getRecord() != null)   if ((this.getRecord().getOpenMode() & DBConstants.OPEN_DONT_CREATE) == 0) {
    boolean loadInitialData=false;
    boolean useTemporaryFilename=false;
    if (this.getDatabase() != null) {
      if (DBConstants.TRUE.equalsIgnoreCase(this.getDatabase().getProperty(DBConstants.LOAD_INITIAL_DATA)))       if ((this.getDatabase().getDatabaseOwner() == null) || (!DBConstants.FALSE.equalsIgnoreCase(this.getDatabase().getDatabaseOwner().getProperty(DBConstants.LOAD_INITIAL_DATA))))       loadInitialData=true;
      if (DBConstants.TRUE.equalsIgnoreCase(this.getDatabase().getProperty(SQLParams.RENAME_TABLE_SUPPORT)))       useTemporaryFilename=true;
    }
    if (this.getRecord().isQueryRecord()) {
      for (int i=0; i < this.getRecord().getRecordlistCount(); i++) {
        Record record=this.getRecord().getRecordlistAt(i);
        try {
          if (!record.getTable().create())           return false;
        }
 catch (        DBException e) {
          continue;
        }
        if (loadInitialData) {
          RecordOwner recordOwner=record.getRecordOwner();
          if (recordOwner == null)           record.setRecordOwner(this.getRecord().getRecordOwner());
          record.getTable().loadInitialData();
          if (recordOwner == null)           record.setRecordOwner(recordOwner);
        }
      }
      return true;
    }
    String tableName=null;
    boolean bSuccess=true;
    try {
      if (useTemporaryFilename)       if (loadInitialData) {
        tableName=this.getRecord().getTableNames(false);
        this.getRecord().setTableNames(tableName + "String_Node_Str");
      }
      bSuccess=this.create();
      if (bSuccess)       if (loadInitialData) {
        this.loadInitialData();
        if (useTemporaryFilename)         this.renameTable(tableName + "String_Node_Str",tableName);
      }
    }
 catch (    DBException e) {
      if (tableName != null)       this.getRecord().setTableNames(tableName);
      int oldOpenMode=this.getRecord().getOpenMode();
      this.getRecord().setOpenMode(oldOpenMode | DBConstants.OPEN_DONT_CREATE);
      int oldKeyArea=this.getRecord().getDefaultOrder();
      int i=0;
      for (; i < 120; i++) {
        try {
          this.getRecord().setKeyArea(0);
          this.doSeek(DBConstants.EQUALS);
          break;
        }
 catch (        DBException e2) {
        }
 finally {
          this.getRecord().setKeyArea(oldKeyArea);
        }
synchronized (this) {
          try {
            this.wait(1000);
          }
 catch (          InterruptedException e1) {
            e1.printStackTrace();
          }
        }
      }
      if (i == 20) {
        oldOpenMode=oldOpenMode | DBConstants.OPEN_DONT_CREATE;
        e.printStackTrace();
      }
      this.getRecord().setOpenMode(oldOpenMode);
    }
 finally {
      if (tableName != null)       this.getRecord().setTableNames(tableName);
    }
    return bSuccess;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Check out this error, if it says table not found, create a new table.
 * @param ex error thrown.
 * @return true if file was not found and was successfully created.
 * @exception DBException Converts and returns SQLExceptions, or if no rows updated, throws INVALID_RECORD.
 */
public boolean createIfNotFoundError(DBException ex) throws DBException {
  if (ex.getErrorCode() == DBConstants.FILE_NOT_FOUND)   if (this.getRecord() != null)   if ((this.getRecord().getOpenMode() & DBConstants.OPEN_DONT_CREATE) == 0) {
    boolean loadInitialData=false;
    boolean useTemporaryFilename=false;
    if (this.getDatabase() != null) {
      if (DBConstants.TRUE.equalsIgnoreCase(this.getDatabase().getProperty(DBConstants.LOAD_INITIAL_DATA)))       if ((this.getDatabase().getDatabaseOwner() == null) || (!DBConstants.FALSE.equalsIgnoreCase(this.getDatabase().getDatabaseOwner().getProperty(DBConstants.LOAD_INITIAL_DATA))))       loadInitialData=true;
      if (DBConstants.TRUE.equalsIgnoreCase(this.getDatabase().getProperty(SQLParams.RENAME_TABLE_SUPPORT)))       useTemporaryFilename=true;
    }
    if (this.getRecord().isQueryRecord()) {
      for (int i=0; i < this.getRecord().getRecordlistCount(); i++) {
        Record record=this.getRecord().getRecordlistAt(i);
        try {
          if (!record.getTable().create())           return false;
        }
 catch (        DBException e) {
          continue;
        }
        if (loadInitialData) {
          RecordOwner recordOwner=record.getRecordOwner();
          if (recordOwner == null)           record.setRecordOwner(this.getRecord().getRecordOwner());
          record.getTable().loadInitialData();
          if (recordOwner == null)           record.setRecordOwner(recordOwner);
        }
      }
      return true;
    }
    String tableName=null;
    boolean bSuccess=true;
    try {
      if (useTemporaryFilename)       if (loadInitialData) {
        tableName=this.getRecord().getTableNames(false);
        this.getRecord().setTableNames(tableName + TEMP_SUFFIX);
      }
      bSuccess=this.create();
      if (bSuccess)       if (loadInitialData) {
        this.loadInitialData();
        if (useTemporaryFilename)         this.renameTable(tableName + TEMP_SUFFIX,tableName);
      }
    }
 catch (    DBException e) {
      if (tableName != null)       this.getRecord().setTableNames(tableName);
      int oldOpenMode=this.getRecord().getOpenMode();
      this.getRecord().setOpenMode(oldOpenMode | DBConstants.OPEN_DONT_CREATE);
      int oldKeyArea=this.getRecord().getDefaultOrder();
      int i=0;
      for (; i < 120; i++) {
        try {
          this.getRecord().setKeyArea(0);
          this.doSeek(DBConstants.EQUALS);
          break;
        }
 catch (        DBException e2) {
        }
 finally {
          this.getRecord().setKeyArea(oldKeyArea);
        }
synchronized (this) {
          try {
            this.wait(1000);
          }
 catch (          InterruptedException e1) {
            e1.printStackTrace();
          }
        }
      }
      if (i == 20) {
        oldOpenMode=oldOpenMode | DBConstants.OPEN_DONT_CREATE;
        e.printStackTrace();
      }
      this.getRecord().setOpenMode(oldOpenMode);
    }
 finally {
      if (tableName != null)       this.getRecord().setTableNames(tableName);
    }
    return bSuccess;
  }
  return false;
}