Program: 45364
Project: 45364
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);
  String strFilename=record.getArchiveFilename(false);
  InputStream inputStream=null;
  if (Record.findRecordOwner(record) != null)   if (Record.findRecordOwner(record).getTask() != null)   inputStream=Record.findRecordOwner(record).getTask().getInputStream(strFilename);
  org.jbundle.base.db.xmlutil.XmlInOut xml=new org.jbundle.base.db.xmlutil.XmlInOut(null,null,null);
  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);
  boolean bSuccess=false;
  try {
    bSuccess=xml.importXML(table,strFilename,inputStream);
  }
 catch (  Exception ex) {
    Utility.getLogger().warning("String_Node_Str" + record.getRecordName());
  }
 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);
  String strFilename=record.getArchiveFilename(true);
  InputStream inputStream=null;
  if (Record.findRecordOwner(record) != null)   if (Record.findRecordOwner(record).getTask() != null)   inputStream=Record.findRecordOwner(record).getTask().getInputStream(strFilename);
  org.jbundle.base.db.xmlutil.XmlInOut xml=new org.jbundle.base.db.xmlutil.XmlInOut(null,null,null);
  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);
  boolean bSuccess=false;
  try {
    bSuccess=xml.importXML(table,strFilename,inputStream);
  }
 catch (  Exception ex) {
    Utility.getLogger().warning("String_Node_Str" + record.getRecordName());
  }
 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;
}