Program: 71865
Project: 71865
Buggy source:
/** 
 * populate shema list if the schema is supported
 */
protected void populateSchemaList(){
  if (rootNode != null) {
    removeTreeItem(rootNode);
  }
  if (JdbcPlugin.getDefault().getPluginPreferences().getString(DateSetPreferencePage.SCHEMAS_PREFETCH_CONFIG).equals(ENABLED)) {
    getAvailableSchema();
  }
 else {
    getSpecificSchema(schemaCombo.getText().trim());
  }
  if (schemaCombo.getItemCount() < 1) {
    schemaCombo.add(JdbcPlugin.getResourceString("String_Node_Str"));
    schemaCombo.select(0);
    if (schemaList != null) {
      Iterator it=schemaList.iterator();
      while (it.hasNext())       schemaCombo.add(it.next().toString());
    }
  }
  ArrayList schemaObjectList=new ArrayList();
  if (schemaList != null) {
    int numberOfSchema=0;
    Preferences preferences=JdbcPlugin.getDefault().getPluginPreferences();
    if (preferences.contains(DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA)) {
      numberOfSchema=preferences.getInt(DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA);
    }
 else {
      numberOfSchema=DateSetPreferencePage.DEFAULT_MAX_NUM_OF_SCHEMA;
      preferences.setValue(DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA,numberOfSchema);
    }
    cachedSchemaComboIndex=schemaCombo.getSelectionIndex();
    if (schemaCombo.getSelectionIndex() < 0) {
      String schemaName=schemaCombo.getText().trim();
      if (schemaName.length() != 0) {
        DbObject schemaObj=new DbObject(schemaName,schemaName,DbObject.SCHEMA_TYPE,schemaImage);
        schemaObjectList.add(schemaObj);
      }
 else       schemaCombo.select(0);
    }
    if (schemaCombo.getSelectionIndex() == 0) {
      for (int i=0, count=0; i < schemaList.size() && count < numberOfSchema; i++) {
        String schemaName=(String)schemaList.get(i);
        if (showSystemTableCheckBox.isEnabled() && showSystemTableCheckBox.getSelection()) {
          if (containsTableInSchema(schemaName,true)) {
            DbObject schemaObj=new DbObject(schemaName,schemaName,DbObject.SCHEMA_TYPE,schemaImage);
            schemaObjectList.add(schemaObj);
            count++;
          }
        }
 else         if (containsTableInSchema(schemaName,false)) {
          DbObject schemaObj=new DbObject(schemaName,schemaName,DbObject.SCHEMA_TYPE,schemaImage);
          schemaObjectList.add(schemaObj);
          count++;
        }
      }
    }
 else     if (schemaCombo.getSelectionIndex() > 0) {
      String schemaName=schemaCombo.getItem(schemaCombo.getSelectionIndex());
      DbObject schemaObj=new DbObject(schemaName,schemaName,DbObject.SCHEMA_TYPE,schemaImage);
      schemaObjectList.add(schemaObj);
    }
  }
  TreeItem[] items=Utility.createTreeItems(rootNode,schemaObjectList,SWT.NONE,schemaImage);
  if (items != null && items.length > 0) {
    availableDbObjectsTree.showItem(items[0]);
  }
}

Fixed version (ground truth):
/** 
 * populate shema list if the schema is supported
 */
protected void populateSchemaList(boolean checkEmptySchema){
  if (rootNode != null) {
    removeTreeItem(rootNode);
  }
  if (JdbcPlugin.getDefault().getPluginPreferences().getString(DateSetPreferencePage.SCHEMAS_PREFETCH_CONFIG).equals(ENABLED)) {
    getAvailableSchema();
  }
 else {
    getSpecificSchema(schemaCombo.getText().trim(),checkEmptySchema);
  }
  if (schemaCombo.getItemCount() < 1) {
    schemaCombo.add(JdbcPlugin.getResourceString("String_Node_Str"));
    schemaCombo.select(0);
    if (schemaList != null) {
      Iterator it=schemaList.iterator();
      while (it.hasNext())       schemaCombo.add(it.next().toString());
    }
  }
  ArrayList schemaObjectList=new ArrayList();
  if (schemaList != null) {
    int numberOfSchema=0;
    Preferences preferences=JdbcPlugin.getDefault().getPluginPreferences();
    if (preferences.contains(DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA)) {
      numberOfSchema=preferences.getInt(DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA);
    }
 else {
      numberOfSchema=DateSetPreferencePage.DEFAULT_MAX_NUM_OF_SCHEMA;
      preferences.setValue(DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA,numberOfSchema);
    }
    cachedSchemaComboIndex=schemaCombo.getSelectionIndex();
    if (schemaCombo.getSelectionIndex() < 0) {
      String schemaName=schemaCombo.getText().trim();
      if (schemaName.length() != 0) {
        DbObject schemaObj=new DbObject(schemaName,schemaName,DbObject.SCHEMA_TYPE,schemaImage);
        schemaObjectList.add(schemaObj);
      }
 else       schemaCombo.select(0);
    }
    if (schemaCombo.getSelectionIndex() == 0) {
      for (int i=0, count=0; i < schemaList.size() && count < numberOfSchema; i++) {
        String schemaName=(String)schemaList.get(i);
        if (!checkEmptySchema) {
          DbObject schemaObj=new DbObject(schemaName,schemaName,DbObject.SCHEMA_TYPE,schemaImage);
          schemaObjectList.add(schemaObj);
          count++;
        }
 else {
          boolean showSystemTable=showSystemTableCheckBox.isEnabled() && showSystemTableCheckBox.getSelection();
          if (containsTableInSchema(schemaName,showSystemTable)) {
            DbObject schemaObj=new DbObject(schemaName,schemaName,DbObject.SCHEMA_TYPE,schemaImage);
            schemaObjectList.add(schemaObj);
            count++;
          }
        }
      }
    }
 else     if (schemaCombo.getSelectionIndex() > 0) {
      String schemaName=schemaCombo.getItem(schemaCombo.getSelectionIndex());
      DbObject schemaObj=new DbObject(schemaName,schemaName,DbObject.SCHEMA_TYPE,schemaImage);
      schemaObjectList.add(schemaObj);
    }
  }
  TreeItem[] items=Utility.createTreeItems(rootNode,schemaObjectList,SWT.NONE,schemaImage);
  if (items != null && items.length > 0) {
    availableDbObjectsTree.showItem(items[0]);
  }
}