Program: 79188
Project: 79188
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();
  if (schemaList != null && schemaList.size() > 0) {
    ResultSet tablesRs=null;
    int numTables=0;
    boolean maxRecordsDisplayed=false;
    for (int i=0; i < schemaList.size(); i++) {
      if (maxRecordsDisplayed) {
        break;
      }
      int count=0;
      String schemaName=(String)schemaList.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;
        while (tablesRs.next()) {
          if (count == 0) {
            schema.add(schemaName);
            schemaTreeItem=Utility.createTreeItems(rootNode,schema,SWT.NONE,schemaImage);
            if (schemaTreeItem != null && schemaTreeItem.length > 0)             availableDbObjectsTree.showItem(schemaTreeItem[0]);
          }
          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 (numTables == DbType.MAX_ITEMS_DISPLAY_COUNT) {
            maxRecordsDisplayed=true;
            break;
          }
        }
        if (schemaTreeItem != null && schemaTreeItem.length > 0) {
          TreeItem item[]=Utility.createTreeItems(schemaTreeItem[0],tableList,SWT.NONE,null);
          if (item != null && item.length > 0)           availableDbObjectsTree.showItem(item[0]);
        }
      }
 catch (      SQLException e) {
        e.printStackTrace();
      }
    }
    checkForMaxRecordsDisplayed(maxRecordsDisplayed,tablesRs);
  }
 else {
    ResultSet tablesRs=metaDataProvider.getAlltables(catalogName,null,namePattern,tableType);
    if (tablesRs == null) {
      return;
    }
    int count=0;
    boolean maxRecordsDisplayed=false;
    try {
      Image image=tableImage;
      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;
        }
        DbObject dbObject=new DbObject(tableName,tableName,dbType,image);
        tableList.add(dbObject);
        if (count == DbType.MAX_ITEMS_DISPLAY_COUNT) {
          maxRecordsDisplayed=true;
          break;
        }
      }
      TreeItem item[]=Utility.createTreeItems(rootNode,tableList,SWT.NONE,null);
      if (item != null && item.length > 0)       availableDbObjectsTree.showItem(item[0]);
      checkForMaxRecordsDisplayed(maxRecordsDisplayed,tablesRs);
    }
 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;
    boolean maxRecordsDisplayed=false;
    for (int i=0; i < targetSchemaList.size(); i++) {
      if (maxRecordsDisplayed) {
        break;
      }
      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 (numTables == DbType.MAX_ITEMS_DISPLAY_COUNT) {
            maxRecordsDisplayed=true;
            break;
          }
        }
        if (schemaTreeItem != null && schemaTreeItem.length > 0) {
          TreeItem item[]=Utility.createTreeItems(schemaTreeItem[0],tableList,SWT.NONE,null);
          if (item != null && item.length > 0)           availableDbObjectsTree.showItem(item[0]);
        }
      }
 catch (      SQLException e) {
        e.printStackTrace();
      }
    }
    checkForMaxRecordsDisplayed(maxRecordsDisplayed,tablesRs);
  }
 else {
    ResultSet tablesRs=metaDataProvider.getAlltables(catalogName,null,namePattern,tableType);
    if (tablesRs == null) {
      return;
    }
    int count=0;
    boolean maxRecordsDisplayed=false;
    try {
      Image image=tableImage;
      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;
        }
        DbObject dbObject=new DbObject(tableName,tableName,dbType,image);
        tableList.add(dbObject);
        if (count == DbType.MAX_ITEMS_DISPLAY_COUNT) {
          maxRecordsDisplayed=true;
          break;
        }
      }
      TreeItem item[]=Utility.createTreeItems(rootNode,tableList,SWT.NONE,null);
      if (item != null && item.length > 0)       availableDbObjectsTree.showItem(item[0]);
      checkForMaxRecordsDisplayed(maxRecordsDisplayed,tablesRs);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  addFetchColumnListener();
}