Program: 124837
Project: 124837
Buggy source:
@Override public List<ImportItem> findRelatedImportItems(IProgressMonitor monitor,ResourcesManager resManager,ImportItem importItem,ImportItem[] allImportItemRecords) throws Exception {
  List<ImportItem> relatedItemRecords=new ArrayList<ImportItem>();
  relatedItemRecords.addAll(super.findRelatedImportItems(monitor,resManager,importItem,allImportItemRecords));
  if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopClusterService.class)) {
    IHadoopClusterService hadoopClusterService=(IHadoopClusterService)GlobalServiceRegister.getDefault().getService(IHadoopClusterService.class);
    final Item item=importItem.getItem();
    if (hadoopClusterService != null && hadoopClusterService.isHadoopClusterItem(item)) {
      resolveItem(resManager,importItem);
      String clusterId=item.getProperty().getId();
      for (      ImportItem ir : allImportItemRecords) {
        resolveItem(resManager,ir);
        Item subItem=ir.getItem();
        String hcId=null;
        if (subItem instanceof HadoopSubConnectionItem) {
          hcId=((HadoopSubConnection)((HadoopSubConnectionItem)subItem).getConnection()).getRelativeHadoopClusterId();
        }
 else         if (subItem instanceof DatabaseConnectionItem) {
          hcId=((DatabaseConnection)((DatabaseConnectionItem)subItem).getConnection()).getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
        }
        if (clusterId.equals(hcId)) {
          relatedItemRecords.add(ir);
        }
      }
    }
  }
  return relatedItemRecords;
}

Fixed version (ground truth):
@Override public List<ImportItem> findRelatedImportItems(IProgressMonitor monitor,ResourcesManager resManager,ImportItem importItem,ImportItem[] allImportItemRecords) throws Exception {
  List<ImportItem> relatedItemRecords=new ArrayList<ImportItem>();
  relatedItemRecords.addAll(super.findRelatedImportItems(monitor,resManager,importItem,allImportItemRecords));
  if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopClusterService.class)) {
    IHadoopClusterService hadoopClusterService=(IHadoopClusterService)GlobalServiceRegister.getDefault().getService(IHadoopClusterService.class);
    final Item item=importItem.getItem();
    if (hadoopClusterService != null && hadoopClusterService.isHadoopClusterItem(item)) {
      resolveItem(resManager,importItem);
      HadoopClusterConnection hcConnection=(HadoopClusterConnection)((HadoopClusterConnectionItem)item).getConnection();
      String clusterId=item.getProperty().getId();
      for (      ImportItem ir : allImportItemRecords) {
        resolveItem(resManager,ir);
        Item subItem=ir.getItem();
        String hcId=null;
        if (subItem instanceof HadoopSubConnectionItem) {
          hcId=((HadoopSubConnection)((HadoopSubConnectionItem)subItem).getConnection()).getRelativeHadoopClusterId();
        }
 else         if (subItem instanceof DatabaseConnectionItem) {
          hcId=((DatabaseConnection)((DatabaseConnectionItem)subItem).getConnection()).getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
        }
        if (clusterId.equals(hcId)) {
          if (subItem instanceof HadoopSubConnectionItem) {
            EList<String> connectionList=hcConnection.getConnectionList();
            String subItemId=subItem.getProperty().getId();
            if (!connectionList.contains(subItemId)) {
              connectionList.add(subItemId);
            }
          }
          relatedItemRecords.add(ir);
        }
      }
    }
  }
  return relatedItemRecords;
}