Program: 45363
Project: 45363
Buggy source:
/** 
 * Create a new empty table using the definition in the record.
 * @exception DBException Open errors passed from SQL.
 * @return true if successful.
 */
public boolean loadInitialData() throws DBException {
  BaseTable table=this;
  Record record=table.getRecord();
  while (((record.getDatabaseType() & DBConstants.SHARED_TABLE) != 0) && ((record.getDatabaseType() & DBConstants.BASE_TABLE_CLASS) == 0)) {
    String tableName=record.getTableNames(false);
    Class<?> className=record.getClass().getSuperclass();
    record=Record.makeRecordFromClassName(className.getName(),record.getRecordOwner());
    record.setTableNames(tableName);
    table=record.getTable();
  }
  if (record.getTable() instanceof PassThruTable)   table=this.getPhysicalTable((PassThruTable)record.getTable(),record);
  int iOpenMode=record.getOpenMode();
  record.setOpenMode(DBConstants.OPEN_NORMAL);
  int iCount=record.getFieldCount();
  boolean[] brgCurrentSelection=new boolean[iCount];
  for (int i=0; i < iCount; i++) {
    brgCurrentSelection[i]=record.getField(i).isSelected();
    record.getField(i).setSelected(true);
  }
  BaseBuffer buffer=new VectorBuffer(null);
  buffer.fieldsToBuffer(record);
  org.jbundle.base.db.xmlutil.XmlInOut xml=new org.jbundle.base.db.xmlutil.XmlInOut(null,null,null);
  String filename=record.getArchiveFilename(true);
  String defaultFilename=record.getArchiveFilename(false);
  InputStream inputStream=null;
  if (Record.findRecordOwner(record) != null)   if (Record.findRecordOwner(record).getTask() != null)   inputStream=Record.findRecordOwner(record).getTask().getInputStream(filename);
  boolean bSuccess=false;
  try {
    bSuccess=xml.importXML(table,filename,inputStream);
    if (!bSuccess)     if (!defaultFilename.equals(filename)) {
      if (Record.findRecordOwner(record) != null)       if (Record.findRecordOwner(record).getTask() != null)       inputStream=Record.findRecordOwner(record).getTask().getInputStream(defaultFilename);
      bSuccess=xml.importXML(table,defaultFilename,inputStream);
    }
    if (!bSuccess)     Utility.getLogger().warning("String_Node_Str" + record.getRecordName());
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
 finally {
    xml.free();
  }
  XmlInOut.enableAllBehaviors(record,false,false);
  buffer.bufferToFields(record,DBConstants.DISPLAY,DBConstants.SCREEN_MOVE);
  XmlInOut.enableAllBehaviors(record,true,true);
  for (int i=0; i < iCount; i++) {
    record.getField(i).setSelected(brgCurrentSelection[i]);
  }
  record.setOpenMode(iOpenMode);
  if (record != this.getRecord())   record.free();
  return bSuccess;
}

Fixed version (ground truth):
/** 
 * Create a new empty table using the definition in the record.
 * @exception DBException Open errors passed from SQL.
 * @return true if successful.
 */
public boolean loadInitialData() throws DBException {
  BaseTable table=this;
  Record record=table.getRecord();
  while (((record.getDatabaseType() & DBConstants.SHARED_TABLE) != 0) && ((record.getDatabaseType() & DBConstants.BASE_TABLE_CLASS) == 0)) {
    String tableName=record.getTableNames(false);
    Class<?> className=record.getClass().getSuperclass();
    record=Record.makeRecordFromClassName(className.getName(),record.getRecordOwner());
    record.setTableNames(tableName);
    table=record.getTable();
  }
  if (record.getTable() instanceof PassThruTable)   table=this.getPhysicalTable((PassThruTable)record.getTable(),record);
  int iOpenMode=record.getOpenMode();
  record.setOpenMode(DBConstants.OPEN_NORMAL);
  int iCount=record.getFieldCount();
  boolean[] brgCurrentSelection=new boolean[iCount];
  for (int i=0; i < iCount; i++) {
    brgCurrentSelection[i]=record.getField(i).isSelected();
    record.getField(i).setSelected(true);
  }
  BaseBuffer buffer=new VectorBuffer(null);
  buffer.fieldsToBuffer(record);
  org.jbundle.base.db.xmlutil.XmlInOut xml=new org.jbundle.base.db.xmlutil.XmlInOut(null,null,null);
  String filename=record.getArchiveFilename(true);
  String defaultFilename=record.getArchiveFilename(false);
  InputStream inputStream=null;
  if (Record.findRecordOwner(record) != null)   if (Record.findRecordOwner(record).getTask() != null)   inputStream=Record.findRecordOwner(record).getTask().getInputStream(filename);
  boolean bSuccess=false;
  try {
    bSuccess=xml.importXML(table,filename,inputStream);
    if (!bSuccess)     if (!defaultFilename.equals(filename)) {
      if (Record.findRecordOwner(record) != null)       if (Record.findRecordOwner(record).getTask() != null)       inputStream=Record.findRecordOwner(record).getTask().getInputStream(defaultFilename);
      bSuccess=xml.importXML(table,defaultFilename,inputStream);
    }
    if (!bSuccess)     Utility.getLogger().warning("String_Node_Str" + ((record.getRecordName().endsWith(TEMP_SUFFIX)) ? record.getRecordName().substring(0,record.getRecordName().length() - TEMP_SUFFIX.length()) : record.getRecordName()) + "String_Node_Str"+ filename);
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
 finally {
    xml.free();
  }
  XmlInOut.enableAllBehaviors(record,false,false);
  buffer.bufferToFields(record,DBConstants.DISPLAY,DBConstants.SCREEN_MOVE);
  XmlInOut.enableAllBehaviors(record,true,true);
  for (int i=0; i < iCount; i++) {
    record.getField(i).setSelected(brgCurrentSelection[i]);
  }
  record.setOpenMode(iOpenMode);
  if (record != this.getRecord())   record.free();
  return bSuccess;
}