Program: 79092
Project: 79092
Buggy source:
protected void populateTableList(){
  if (rootNode != null) {
    availableDbObjectsTree.removeAll();
    setRootElement();
  }
  String namePattern=null;
  String[] tableType=null;
  cachedSearchTxt=searchTxt.getText();
  namePattern=getTailoredSearchText(namePattern);
  String dbtype=getSelectedDbType();
  cachedDbType=dbtype;
  if (dbtype != null) {
    if (DbType.TABLE_STRING.equalsIgnoreCase(dbtype) || DbType.VIEW_STRING.equalsIgnoreCase(dbtype)) {
      tableType=new String[]{dbtype};
    }
  }
  String catalogName=metaDataProvider.getCatalog();
  ArrayList tableList=new ArrayList();
  ArrayList targetSchemaList=new ArrayList();
  ResultSet tablesRs=null;
  ArrayList procedureRs=null;
  if (schemaList != null && schemaList.size() > 0) {
    cachedSchemaComboIndex=schemaCombo.getSelectionIndex();
    if (schemaCombo.getSelectionIndex() == 0) {
      targetSchemaList=schemaList;
    }
 else {
      targetSchemaList.add(schemaCombo.getItem(schemaCombo.getSelectionIndex()));
    }
    int numTables=0;
    for (int i=0; i < targetSchemaList.size(); i++) {
      int count=0;
      String schemaName=(String)targetSchemaList.get(i);
      if (metaDataProvider.isProcedureSupported())       procedureRs=metaDataProvider.getAllProcedure(catalogName,schemaName,namePattern);
      if (!DbType.PROCEDURE_STRING.equalsIgnoreCase(dbtype))       tablesRs=metaDataProvider.getAlltables(catalogName,schemaName,namePattern,tableType);
      tableList=new ArrayList();
      if (tablesRs == null && procedureRs == null) {
        continue;
      }
      try {
        ArrayList schema=new ArrayList();
        TreeItem schemaTreeItem[]=null;
        Image image=tableImage;
        if (count == 0) {
          schema.add(schemaName);
          schemaTreeItem=Utility.createTreeItems(rootNode,schema,SWT.NONE,schemaImage);
          if (schemaTreeItem != null && schemaTreeItem.length > 0)           availableDbObjectsTree.showItem(schemaTreeItem[0]);
        }
        if (tablesRs != null) {
          while (tablesRs.next()) {
            String tableName=tablesRs.getString("String_Node_Str");
            String type=tablesRs.getString("String_Node_Str");
            if (type.equalsIgnoreCase("String_Node_Str"))             continue;
            count++;
            int dbType=DbObject.TABLE_TYPE;
            if (type.equalsIgnoreCase("String_Node_Str")) {
              image=tableImage;
              dbType=DbObject.TABLE_TYPE;
            }
 else             if (type.equalsIgnoreCase("String_Node_Str")) {
              image=viewImage;
              dbType=DbObject.VIEW_TYPE;
            }
            String fullyQualifiedTableName=tableName;
            if (schemaName != null && schemaName.trim().length() > 0) {
              fullyQualifiedTableName=schemaName + "String_Node_Str" + tableName;
            }
            DbObject dbObject=new DbObject(fullyQualifiedTableName,tableName,dbType,image);
            tableList.add(dbObject);
            numTables++;
          }
        }
        if (needToCreateProcedureNode(dbtype,procedureRs)) {
          String fullyQualifiedTableName="String_Node_Str";
          if (schemaName != null && schemaName.trim().length() > 0) {
            fullyQualifiedTableName=schemaName + "String_Node_Str" + "String_Node_Str";
          }
          DbObject dbObject=new DbObject(fullyQualifiedTableName,"String_Node_Str",DbObject.PROCEDURE_TYPE,tableImage);
          tableList.add(dbObject);
        }
        if (schemaTreeItem != null && schemaTreeItem.length > 0) {
          TreeItem item[]=Utility.createTreeItems(schemaTreeItem[0],tableList,SWT.NONE,null);
          if (expandDbObjectsTree && item != null && item.length > 0) {
            availableDbObjectsTree.showItem(item[0]);
          }
        }
      }
 catch (      SQLException e) {
        e.printStackTrace();
      }
    }
  }
 else {
    if (metaDataProvider.isProcedureSupported())     procedureRs=metaDataProvider.getAllProcedure(catalogName,null,namePattern);
    if (!DbType.PROCEDURE_STRING.equalsIgnoreCase(dbtype))     tablesRs=metaDataProvider.getAlltables(catalogName,null,namePattern,tableType);
    if (tablesRs == null && procedureRs == null) {
      return;
    }
    try {
      Image image=tableImage;
      if (tablesRs != null) {
        while (tablesRs.next()) {
          String type=tablesRs.getString("String_Node_Str");
          if (type.equalsIgnoreCase("String_Node_Str"))           continue;
          String tableName=tablesRs.getString("String_Node_Str");
          int dbType=DbObject.TABLE_TYPE;
          if (type.equalsIgnoreCase("String_Node_Str")) {
            image=tableImage;
            dbType=DbObject.TABLE_TYPE;
          }
 else           if (type.equalsIgnoreCase("String_Node_Str")) {
            image=viewImage;
            dbType=DbObject.VIEW_TYPE;
          }
          DbObject dbObject=new DbObject(tableName,tableName,dbType,image);
          tableList.add(dbObject);
        }
      }
      if (needToCreateProcedureNode(dbtype,procedureRs)) {
        String fullyQualifiedTableName="String_Node_Str";
        DbObject dbObject=new DbObject(fullyQualifiedTableName,"String_Node_Str",DbObject.PROCEDURE_TYPE,tableImage);
        tableList.add(dbObject);
      }
      TreeItem item[]=Utility.createTreeItems(rootNode,tableList,SWT.NONE,null);
      if (item != null && item.length > 0)       availableDbObjectsTree.showItem(item[0]);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  addFetchColumnListener();
}

Fixed version (ground truth):
protected void populateTableList(){
  if (rootNode != null) {
    availableDbObjectsTree.removeAll();
    setRootElement();
  }
  String namePattern=null;
  String[] tableType=null;
  cachedSearchTxt=searchTxt.getText();
  namePattern=getTailoredSearchText(searchTxt.getText());
  String dbtype=getSelectedDbType();
  cachedDbType=dbtype;
  if (dbtype != null) {
    if (DbType.TABLE_STRING.equalsIgnoreCase(dbtype) || DbType.VIEW_STRING.equalsIgnoreCase(dbtype)) {
      tableType=new String[]{dbtype};
    }
  }
  String catalogName=metaDataProvider.getCatalog();
  ArrayList tableList=new ArrayList();
  ArrayList targetSchemaList=new ArrayList();
  ResultSet tablesRs=null;
  ArrayList procedureRs=null;
  if (schemaList != null && schemaList.size() > 0) {
    cachedSchemaComboIndex=schemaCombo.getSelectionIndex();
    if (schemaCombo.getSelectionIndex() == 0) {
      targetSchemaList=schemaList;
    }
 else {
      targetSchemaList.add(schemaCombo.getItem(schemaCombo.getSelectionIndex()));
    }
    int numTables=0;
    for (int i=0; i < targetSchemaList.size(); i++) {
      int count=0;
      String schemaName=(String)targetSchemaList.get(i);
      if (metaDataProvider.isProcedureSupported())       procedureRs=metaDataProvider.getAllProcedure(catalogName,schemaName,namePattern);
      if (!DbType.PROCEDURE_STRING.equalsIgnoreCase(dbtype))       tablesRs=metaDataProvider.getAlltables(catalogName,schemaName,namePattern,tableType);
      tableList=new ArrayList();
      if (tablesRs == null && procedureRs == null) {
        continue;
      }
      try {
        ArrayList schema=new ArrayList();
        TreeItem schemaTreeItem[]=null;
        Image image=tableImage;
        if (count == 0) {
          schema.add(schemaName);
          schemaTreeItem=Utility.createTreeItems(rootNode,schema,SWT.NONE,schemaImage);
          if (schemaTreeItem != null && schemaTreeItem.length > 0)           availableDbObjectsTree.showItem(schemaTreeItem[0]);
        }
        if (tablesRs != null) {
          while (tablesRs.next()) {
            String tableName=tablesRs.getString("String_Node_Str");
            String type=tablesRs.getString("String_Node_Str");
            if (type.equalsIgnoreCase("String_Node_Str"))             continue;
            count++;
            int dbType=DbObject.TABLE_TYPE;
            if (type.equalsIgnoreCase("String_Node_Str")) {
              image=tableImage;
              dbType=DbObject.TABLE_TYPE;
            }
 else             if (type.equalsIgnoreCase("String_Node_Str")) {
              image=viewImage;
              dbType=DbObject.VIEW_TYPE;
            }
            String fullyQualifiedTableName=tableName;
            if (schemaName != null && schemaName.trim().length() > 0) {
              fullyQualifiedTableName=schemaName + "String_Node_Str" + tableName;
            }
            DbObject dbObject=new DbObject(fullyQualifiedTableName,tableName,dbType,image);
            tableList.add(dbObject);
            numTables++;
          }
        }
        if (needToCreateProcedureNode(dbtype,procedureRs)) {
          String fullyQualifiedTableName="String_Node_Str";
          if (schemaName != null && schemaName.trim().length() > 0) {
            fullyQualifiedTableName=schemaName + "String_Node_Str" + "String_Node_Str";
          }
          DbObject dbObject=new DbObject(fullyQualifiedTableName,"String_Node_Str",DbObject.PROCEDURE_TYPE,tableImage);
          tableList.add(dbObject);
        }
        if (schemaTreeItem != null && schemaTreeItem.length > 0) {
          TreeItem item[]=Utility.createTreeItems(schemaTreeItem[0],tableList,SWT.NONE,null);
          if (expandDbObjectsTree && item != null && item.length > 0) {
            availableDbObjectsTree.showItem(item[0]);
          }
        }
      }
 catch (      SQLException e) {
        e.printStackTrace();
      }
    }
  }
 else {
    if (metaDataProvider.isProcedureSupported())     procedureRs=metaDataProvider.getAllProcedure(catalogName,null,namePattern);
    if (!DbType.PROCEDURE_STRING.equalsIgnoreCase(dbtype))     tablesRs=metaDataProvider.getAlltables(catalogName,null,namePattern,tableType);
    if (tablesRs == null && procedureRs == null) {
      return;
    }
    try {
      Image image=tableImage;
      if (tablesRs != null) {
        while (tablesRs.next()) {
          String tableName=tablesRs.getString("String_Node_Str");
          String type=tablesRs.getString("String_Node_Str");
          if (type.equalsIgnoreCase("String_Node_Str"))           continue;
          int dbType=DbObject.TABLE_TYPE;
          if (type.equalsIgnoreCase("String_Node_Str")) {
            image=tableImage;
            dbType=DbObject.TABLE_TYPE;
          }
 else           if (type.equalsIgnoreCase("String_Node_Str")) {
            image=viewImage;
            dbType=DbObject.VIEW_TYPE;
          }
          DbObject dbObject=new DbObject(tableName,tableName,dbType,image);
          tableList.add(dbObject);
        }
      }
      if (needToCreateProcedureNode(dbtype,procedureRs)) {
        String fullyQualifiedTableName="String_Node_Str";
        DbObject dbObject=new DbObject(fullyQualifiedTableName,"String_Node_Str",DbObject.PROCEDURE_TYPE,tableImage);
        tableList.add(dbObject);
      }
      TreeItem item[]=Utility.createTreeItems(rootNode,tableList,SWT.NONE,null);
      if (item != null && item.length > 0)       availableDbObjectsTree.showItem(item[0]);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  addFetchColumnListener();
}