Program: 130172
Project: 130172
Buggy source:
private void createTables(RepositoryNode recBinNode,RepositoryNode node,final IRepositoryViewObject repObj,Connection metadataConnection,List<IRepositoryViewObject> validationRules){
  if (metadataConnection instanceof DatabaseConnection) {
    RepositoryNode tablesNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
    node.getChildren().add(tablesNode);
    RepositoryNode viewsNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
    node.getChildren().add(viewsNode);
    RepositoryNode synonymsNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
    node.getChildren().add(synonymsNode);
    DatabaseConnection dbconn=(DatabaseConnection)metadataConnection;
    List<MetadataTable> allTables=ConnectionHelper.getTablesWithOrders(dbconn);
    Iterator metadataTables=allTables.iterator();
    while (metadataTables.hasNext()) {
      org.talend.core.model.metadata.builder.connection.MetadataTable metadataTable=(org.talend.core.model.metadata.builder.connection.MetadataTable)metadataTables.next();
      if (SubItemHelper.isDeleted(metadataTable)) {
        continue;
      }
      String typeTable=null;
      if (metadataTable != null && metadataTable.getTableType() != null) {
        typeTable=metadataTable.getTableType();
        if (typeTable.equals(MetadataManager.TYPE_TABLE)) {
          createTable(recBinNode,tablesNode,repObj,metadataTable,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
        }
 else         if (typeTable.equals(MetadataManager.TYPE_VIEW)) {
          createTable(recBinNode,viewsNode,repObj,metadataTable,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
        }
 else         if (typeTable.equals(MetadataManager.TYPE_SYNONYM)) {
          createTable(recBinNode,synonymsNode,repObj,metadataTable,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
        }
 else         if (typeTable.equals(MetadataManager.TYPE_ALIAS)) {
          createTable(recBinNode,synonymsNode,repObj,metadataTable,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
        }
      }
 else {
        createTable(recBinNode,tablesNode,repObj,metadataTable,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
      }
    }
    if (!ConnectionUtils.isHiveConnection(dbconn.getURL())) {
      RepositoryNode queriesNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
      node.getChildren().add(queriesNode);
      QueriesConnection queriesConnection=(metadataConnection).getQueries();
      if (queriesConnection != null) {
        createTables(recBinNode,queriesNode,repObj,queriesConnection.getQuery(),ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
      }
    }
    Item item=node.getObject().getProperty().getItem();
    if (item instanceof DatabaseConnectionItem) {
      DatabaseConnectionItem connectionItem=(DatabaseConnectionItem)item;
      DatabaseConnection connection=(DatabaseConnection)connectionItem.getConnection();
      if (PluginChecker.isCDCPluginLoaded()) {
        ICDCProviderService service=(ICDCProviderService)GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
        if (service != null && service.canCreateCDCConnection(connection)) {
          RepositoryNode cdcNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
          node.getChildren().add(cdcNode);
          service.createCDCTypes(recBinNode,cdcNode,connection.getCdcConns());
        }
      }
    }
  }
 else   if (metadataConnection instanceof SAPConnection) {
    createSAPTableNodes(recBinNode,repObj,metadataConnection,node,validationRules);
    StableRepositoryNode functionNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
    functionNode.setChildrenObjectType(ERepositoryObjectType.METADATA_SAP_FUNCTION);
    node.getChildren().add(functionNode);
    createSAPFunctionNodes(recBinNode,repObj,metadataConnection,functionNode,validationRules);
    StableRepositoryNode iDocNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
    iDocNode.setChildrenObjectType(ERepositoryObjectType.METADATA_SAP_IDOC);
    node.getChildren().add(iDocNode);
    createSAPIDocNodes(recBinNode,repObj,metadataConnection,iDocNode);
  }
 else   if (metadataConnection instanceof SalesforceSchemaConnection) {
    createSalesforceModuleNodes(recBinNode,repObj,metadataConnection,node,validationRules);
  }
 else {
    Set<org.talend.core.model.metadata.builder.connection.MetadataTable> tableset=ConnectionHelper.getTables(metadataConnection);
    EList tables=new BasicEList();
    tables.addAll(tableset);
    createTables(recBinNode,node,repObj,tables,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
  }
}

Fixed version (ground truth):
private void createTables(RepositoryNode recBinNode,RepositoryNode node,final IRepositoryViewObject repObj,Connection metadataConnection,List<IRepositoryViewObject> validationRules){
  if (metadataConnection instanceof DatabaseConnection) {
    RepositoryNode tablesNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
    node.getChildren().add(tablesNode);
    RepositoryNode viewsNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
    node.getChildren().add(viewsNode);
    RepositoryNode synonymsNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
    node.getChildren().add(synonymsNode);
    DatabaseConnection dbconn=(DatabaseConnection)metadataConnection;
    List<MetadataTable> allTables=ConnectionHelper.getTablesWithOrders(dbconn);
    Iterator metadataTables=allTables.iterator();
    while (metadataTables.hasNext()) {
      org.talend.core.model.metadata.builder.connection.MetadataTable metadataTable=(org.talend.core.model.metadata.builder.connection.MetadataTable)metadataTables.next();
      if (SubItemHelper.isDeleted(metadataTable)) {
        continue;
      }
      String typeTable=null;
      if (metadataTable != null && metadataTable.getTableType() != null) {
        typeTable=metadataTable.getTableType();
        if (typeTable.equals(MetadataManager.TYPE_TABLE)) {
          createTable(recBinNode,tablesNode,repObj,metadataTable,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
        }
 else         if (typeTable.equals(MetadataManager.TYPE_VIEW)) {
          createTable(recBinNode,viewsNode,repObj,metadataTable,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
        }
 else         if (typeTable.equals(MetadataManager.TYPE_SYNONYM)) {
          createTable(recBinNode,synonymsNode,repObj,metadataTable,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
        }
 else         if (typeTable.equals(MetadataManager.TYPE_ALIAS)) {
          createTable(recBinNode,synonymsNode,repObj,metadataTable,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
        }
      }
 else {
        createTable(recBinNode,tablesNode,repObj,metadataTable,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
      }
    }
    boolean isImpala=false;
    if (metadataConnection instanceof DatabaseConnection) {
      if (EDatabaseTypeName.IMPALA.getDisplayName().equals(((DatabaseConnection)metadataConnection).getDatabaseType())) {
        isImpala=true;
      }
    }
    if (!ConnectionUtils.isHiveConnection(dbconn.getURL()) || isImpala) {
      RepositoryNode queriesNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
      node.getChildren().add(queriesNode);
      QueriesConnection queriesConnection=(metadataConnection).getQueries();
      if (queriesConnection != null) {
        createTables(recBinNode,queriesNode,repObj,queriesConnection.getQuery(),ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
      }
    }
    Item item=node.getObject().getProperty().getItem();
    if (item instanceof DatabaseConnectionItem) {
      DatabaseConnectionItem connectionItem=(DatabaseConnectionItem)item;
      DatabaseConnection connection=(DatabaseConnection)connectionItem.getConnection();
      if (PluginChecker.isCDCPluginLoaded()) {
        ICDCProviderService service=(ICDCProviderService)GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
        if (service != null && service.canCreateCDCConnection(connection)) {
          RepositoryNode cdcNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
          node.getChildren().add(cdcNode);
          service.createCDCTypes(recBinNode,cdcNode,connection.getCdcConns());
        }
      }
    }
  }
 else   if (metadataConnection instanceof SAPConnection) {
    createSAPTableNodes(recBinNode,repObj,metadataConnection,node,validationRules);
    StableRepositoryNode functionNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
    functionNode.setChildrenObjectType(ERepositoryObjectType.METADATA_SAP_FUNCTION);
    node.getChildren().add(functionNode);
    createSAPFunctionNodes(recBinNode,repObj,metadataConnection,functionNode,validationRules);
    StableRepositoryNode iDocNode=new StableRepositoryNode(node,Messages.getString("String_Node_Str"),ECoreImage.FOLDER_CLOSE_ICON);
    iDocNode.setChildrenObjectType(ERepositoryObjectType.METADATA_SAP_IDOC);
    node.getChildren().add(iDocNode);
    createSAPIDocNodes(recBinNode,repObj,metadataConnection,iDocNode);
  }
 else   if (metadataConnection instanceof SalesforceSchemaConnection) {
    createSalesforceModuleNodes(recBinNode,repObj,metadataConnection,node,validationRules);
  }
 else {
    Set<org.talend.core.model.metadata.builder.connection.MetadataTable> tableset=ConnectionHelper.getTables(metadataConnection);
    EList tables=new BasicEList();
    tables.addAll(tableset);
    createTables(recBinNode,node,repObj,tables,ERepositoryObjectType.METADATA_CON_TABLE,validationRules);
  }
}