Program: 79162
Project: 79162
Buggy source:
protected void populateTableList(){
  if (rootNode != null) {
    availableDbObjectsTree.removeAll();
    setRootElement();
  }
  String namePattern=null;
  String[] tableType=null;
  if (searchTxt.getText().length() > 0) {
    namePattern=searchTxt.getText();
    if (namePattern != null) {
      if (namePattern.lastIndexOf('%') == -1) {
        namePattern=namePattern + "String_Node_Str";
      }
    }
  }
  String dbtype=getSelectedDbType();
  if (dbtype != null && !DbType.ALL_STRING.equalsIgnoreCase(dbtype)) {
    tableType=new String[]{dbtype};
  }
  String catalogName=metaDataProvider.getCatalog();
  ArrayList tableList=new ArrayList();
  ArrayList targetSchemaList=new ArrayList();
  if (schemaList != null && schemaList.size() > 0) {
    if (schemaCombo.getSelectionIndex() == 0) {
      targetSchemaList=schemaList;
    }
 else {
      targetSchemaList.add(schemaCombo.getItem(schemaCombo.getSelectionIndex()));
    }
    ResultSet tablesRs=null;
    int numTables=0;
    for (int i=0; i < targetSchemaList.size(); i++) {
      int count=0;
      String schemaName=(String)targetSchemaList.get(i);
      tablesRs=metaDataProvider.getAlltables(catalogName,schemaName,namePattern,tableType);
      tableList=new ArrayList();
      if (tablesRs == 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]);
        }
        while (tablesRs.next()) {
          count++;
          String tableName=tablesRs.getString("String_Node_Str");
          String type=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;
          }
          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 (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 {
    ResultSet tablesRs=metaDataProvider.getAlltables(catalogName,null,namePattern,tableType);
    if (tablesRs == null) {
      return;
    }
    try {
      Image image=tableImage;
      while (tablesRs.next()) {
        String tableName=tablesRs.getString("String_Node_Str");
        String type=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);
      }
      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;
  if (searchTxt.getText().length() > 0) {
    namePattern=searchTxt.getText();
    if (namePattern != null) {
      if (namePattern.lastIndexOf('%') == -1) {
        namePattern=namePattern + "String_Node_Str";
      }
    }
  }
  String dbtype=getSelectedDbType();
  if (dbtype != null && !DbType.ALL_STRING.equalsIgnoreCase(dbtype)) {
    tableType=new String[]{dbtype};
  }
  String catalogName=metaDataProvider.getCatalog();
  ArrayList tableList=new ArrayList();
  ArrayList targetSchemaList=new ArrayList();
  if (schemaList != null && schemaList.size() > 0) {
    if (schemaCombo.getSelectionIndex() == 0) {
      targetSchemaList=schemaList;
    }
 else {
      targetSchemaList.add(schemaCombo.getItem(schemaCombo.getSelectionIndex()));
    }
    ResultSet tablesRs=null;
    int numTables=0;
    for (int i=0; i < targetSchemaList.size(); i++) {
      int count=0;
      String schemaName=(String)targetSchemaList.get(i);
      tablesRs=metaDataProvider.getAlltables(catalogName,schemaName,namePattern,tableType);
      tableList=new ArrayList();
      if (tablesRs == 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]);
        }
        while (tablesRs.next()) {
          if (tablesRs.getString("String_Node_Str").equalsIgnoreCase("String_Node_Str"))           continue;
          count++;
          String tableName=tablesRs.getString("String_Node_Str");
          String type=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;
          }
          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 (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 {
    ResultSet tablesRs=metaDataProvider.getAlltables(catalogName,null,namePattern,tableType);
    if (tablesRs == null) {
      return;
    }
    try {
      Image image=tableImage;
      while (tablesRs.next()) {
        if (tablesRs.getString("String_Node_Str").equalsIgnoreCase("String_Node_Str"))         continue;
        String tableName=tablesRs.getString("String_Node_Str");
        String type=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);
      }
      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();
}