Program: 74394
Project: 74394
Buggy source:
/** 
 * Return an array of RecordToken, one for each occupant of the room.
 * @return An array of RecordToken, or null if there is no database update.
 * @throws IllegalActionException If the database query fails.
 */
public ArrayToken getOccupants() throws IllegalActionException {
  String databaseName=databaseManager.stringValue();
  CompositeActor container=(CompositeActor)getContainer();
  NamedObj database=container.getEntity(databaseName);
  while (!(database instanceof DatabaseManager)) {
    container=(CompositeActor)container.getContainer();
    if (container == null) {
      throw new IllegalActionException(this,"String_Node_Str" + databaseName);
    }
    database=container.getEntity(databaseName);
  }
  StringBuffer sqlQuery=new StringBuffer();
  sqlQuery.append("String_Node_Str");
  Iterator columnsEntries=((RecordToken)columns.getToken()).labelSet().iterator();
  int i=0;
  while (columnsEntries.hasNext()) {
    if (i++ > 0) {
      sqlQuery.append("String_Node_Str");
    }
    String label=(String)columnsEntries.next();
    sqlQuery.append(label);
  }
  sqlQuery.append("String_Node_Str");
  sqlQuery.append(table.stringValue());
  sqlQuery.append("String_Node_Str");
  RecordToken patternValue=(RecordToken)pattern.getToken();
  Iterator patternEntries=patternValue.labelSet().iterator();
  i=0;
  while (patternEntries.hasNext()) {
    if (i++ > 0) {
      sqlQuery.append("String_Node_Str");
    }
    String label=(String)patternEntries.next();
    sqlQuery.append("String_Node_Str");
    sqlQuery.append(label);
    sqlQuery.append("String_Node_Str");
    sqlQuery.append(patternValue.get(label));
    sqlQuery.append("String_Node_Str");
  }
  PreparedStatement statement=null;
  ArrayList<RecordToken> occupants=new ArrayList<RecordToken>();
  try {
    Connection connection=((DatabaseManager)database).getConnection();
    if (connection == null) {
      return null;
    }
    statement=connection.prepareStatement(sqlQuery.toString());
    ResultSet rset=statement.executeQuery();
    while (rset.next()) {
      HashMap<String,Token> map=new HashMap<String,Token>();
      String lastName=rset.getString("String_Node_Str");
      if (lastName == null) {
        lastName="String_Node_Str";
      }
      map.put("String_Node_Str",new StringToken(lastName));
      String desk=rset.getString("String_Node_Str");
      if (desk == null) {
        desk="String_Node_Str";
      }
      map.put("String_Node_Str",new StringToken(desk));
      RecordToken token=new RecordToken(map);
      occupants.add(token);
    }
  }
 catch (  SQLException e) {
    throw new IllegalActionException(this,e,"String_Node_Str");
  }
  RecordToken[] array=new RecordToken[occupants.size()];
  int k=0;
  for (  RecordToken recordToken : occupants) {
    array[k++]=recordToken;
  }
  ArrayToken result=new ArrayToken(array);
  return result;
}

Fixed version (ground truth):
/** 
 * Return an array of RecordToken, one for each occupant of the room.
 * @return An array of RecordToken, or null if there is no database update.
 * @throws IllegalActionException If the database query fails.
 */
public ArrayToken getOccupants() throws IllegalActionException {
  String databaseName=databaseManager.stringValue();
  CompositeActor container=(CompositeActor)getContainer();
  NamedObj database=container.getEntity(databaseName);
  while (!(database instanceof DatabaseManager)) {
    container=(CompositeActor)container.getContainer();
    if (container == null) {
      throw new IllegalActionException(this,"String_Node_Str" + databaseName);
    }
    database=container.getEntity(databaseName);
  }
  StringBuffer sqlQuery=new StringBuffer();
  sqlQuery.append("String_Node_Str");
  Iterator columnsEntries=((RecordToken)columns.getToken()).labelSet().iterator();
  int i=0;
  while (columnsEntries.hasNext()) {
    if (i++ > 0) {
      sqlQuery.append("String_Node_Str");
    }
    String label=(String)columnsEntries.next();
    sqlQuery.append(label);
  }
  sqlQuery.append("String_Node_Str");
  sqlQuery.append(table.stringValue());
  sqlQuery.append("String_Node_Str");
  RecordToken patternValue=(RecordToken)pattern.getToken();
  Iterator patternEntries=patternValue.labelSet().iterator();
  i=0;
  while (patternEntries.hasNext()) {
    if (i++ > 0) {
      sqlQuery.append("String_Node_Str");
    }
    String label=(String)patternEntries.next();
    sqlQuery.append("String_Node_Str");
    sqlQuery.append(label);
    sqlQuery.append("String_Node_Str");
  }
  PreparedStatement statement=null;
  ArrayList<RecordToken> occupants=new ArrayList<RecordToken>();
  try {
    Connection connection=((DatabaseManager)database).getConnection();
    if (connection == null) {
      return null;
    }
    statement=connection.prepareStatement(sqlQuery.toString());
    patternEntries=patternValue.labelSet().iterator();
    i=1;
    while (patternEntries.hasNext()) {
      String label=(String)patternEntries.next();
      statement.setString(i++,patternValue.get(label).toString());
    }
    ResultSet rset=statement.executeQuery();
    while (rset.next()) {
      HashMap<String,Token> map=new HashMap<String,Token>();
      String lastName=rset.getString("String_Node_Str");
      if (lastName == null) {
        lastName="String_Node_Str";
      }
      map.put("String_Node_Str",new StringToken(lastName));
      String desk=rset.getString("String_Node_Str");
      if (desk == null) {
        desk="String_Node_Str";
      }
      map.put("String_Node_Str",new StringToken(desk));
      RecordToken token=new RecordToken(map);
      occupants.add(token);
    }
  }
 catch (  SQLException e) {
    throw new IllegalActionException(this,e,"String_Node_Str");
  }
  RecordToken[] array=new RecordToken[occupants.size()];
  int k=0;
  for (  RecordToken recordToken : occupants) {
    array[k++]=recordToken;
  }
  ArrayToken result=new ArrayToken(array);
  return result;
}