Program: 129490
Project: 129490
Buggy source:
private void fillPkandFk(ColumnSet colSet,Map<String,TdColumn> columnMap,DatabaseMetaData dbJDBCMetadata,String catalogName,String schemaName,String tableName) throws Exception {
  if (columnMap.size() > 0) {
    Map<String,ForeignKey> foreignKeysMap=new HashMap<String,ForeignKey>();
    if (orgomg.cwm.resource.relational.RelationalPackage.eINSTANCE.getTable().isSuperTypeOf(colSet.eClass())) {
      try {
        if (MetadataConnectionUtils.isOdbcExcel(dbJDBCMetadata) || MetadataConnectionUtils.isAccess(dbJDBCMetadata) || MetadataConnectionUtils.isHive(dbJDBCMetadata)) {
          log.info("String_Node_Str");
          return;
        }
        ResultSet pkResult=dbJDBCMetadata.getPrimaryKeys(catalogName,schemaName,tableName);
        PrimaryKey primaryKey=null;
        while (pkResult.next()) {
          String colName=pkResult.getString(GetPrimaryKey.COLUMN_NAME.name());
          String pkName=pkResult.getString(GetPrimaryKey.PK_NAME.name());
          if (pkName == null) {
            continue;
          }
          if (primaryKey == null) {
            primaryKey=orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createPrimaryKey();
            primaryKey.setName(pkName);
          }
 else           if (!pkName.equals(primaryKey.getName())) {
            throw new Exception("String_Node_Str" + colSet + "String_Node_Str");
          }
          columnMap.get(colName).getUniqueKey().add(primaryKey);
          columnMap.get(colName).setKey(true);
          TableHelper.addPrimaryKey((TdTable)colSet,primaryKey);
        }
        pkResult.close();
        ForeignKey foreignKey=null;
        ResultSet fkResult=null;
        try {
          fkResult=dbJDBCMetadata.getImportedKeys(catalogName,schemaName,tableName);
        }
 catch (        Exception e) {
          log.warn(e,e);
        }
        if (fkResult != null) {
          while (fkResult.next()) {
            String fkname=fkResult.getString(GetForeignKey.FK_NAME.name());
            String colName=fkResult.getString(GetForeignKey.FKCOLUMN_NAME.name());
            if (foreignKey == null || foreignKeysMap.get(fkname) == null) {
              foreignKey=orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createForeignKey();
              foreignKey.setName(fkname);
              foreignKeysMap.put(fkname,foreignKey);
            }
            columnMap.get(colName).getKeyRelationship().add(foreignKey);
            columnMap.get(colName).setKey(true);
          }
          fkResult.close();
          TableHelper.addForeignKeys((TdTable)colSet,Arrays.asList(foreignKeysMap.values().toArray(new ForeignKey[foreignKeysMap.values().size()])));
        }
      }
 catch (      SQLException e) {
        log.error(e,e);
      }
    }
  }
}

Fixed version (ground truth):
private void fillPkandFk(ColumnSet colSet,Map<String,TdColumn> columnMap,DatabaseMetaData dbJDBCMetadata,String catalogName,String schemaName,String tableName) throws Exception {
  if (columnMap.size() > 0) {
    Map<String,ForeignKey> foreignKeysMap=new HashMap<String,ForeignKey>();
    if (orgomg.cwm.resource.relational.RelationalPackage.eINSTANCE.getTable().isSuperTypeOf(colSet.eClass())) {
      try {
        if (MetadataConnectionUtils.isOdbcExcel(dbJDBCMetadata) || MetadataConnectionUtils.isAccess(dbJDBCMetadata) || MetadataConnectionUtils.isHive(dbJDBCMetadata)) {
          log.info("String_Node_Str");
          return;
        }
        ResultSet pkResult=dbJDBCMetadata.getPrimaryKeys(catalogName,schemaName,tableName);
        PrimaryKey primaryKey=null;
        while (pkResult.next()) {
          String colName=pkResult.getString(GetPrimaryKey.COLUMN_NAME.name());
          String pkName=pkResult.getString(GetPrimaryKey.PK_NAME.name());
          if (pkName == null) {
            continue;
          }
          if (primaryKey == null) {
            primaryKey=orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createPrimaryKey();
            primaryKey.setName(pkName);
          }
 else           if (!pkName.equals(primaryKey.getName())) {
            throw new Exception("String_Node_Str" + colSet + "String_Node_Str");
          }
          columnMap.get(colName).getUniqueKey().add(primaryKey);
          columnMap.get(colName).setKey(true);
          TableHelper.addPrimaryKey((TdTable)colSet,primaryKey);
        }
        pkResult.close();
        ForeignKey foreignKey=null;
        ResultSet fkResult=null;
        try {
          fkResult=dbJDBCMetadata.getImportedKeys(catalogName,schemaName,tableName);
        }
 catch (        Exception e) {
          log.warn(e,e);
        }
        if (fkResult != null) {
          while (fkResult.next()) {
            String fkname=fkResult.getString(GetForeignKey.FK_NAME.name());
            String colName=fkResult.getString(GetForeignKey.FKCOLUMN_NAME.name());
            if (foreignKey == null || foreignKeysMap.get(fkname) == null) {
              foreignKey=orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createForeignKey();
              foreignKey.setName(fkname);
              foreignKeysMap.put(fkname,foreignKey);
            }
            columnMap.get(colName).getKeyRelationship().add(foreignKey);
          }
          fkResult.close();
          TableHelper.addForeignKeys((TdTable)colSet,Arrays.asList(foreignKeysMap.values().toArray(new ForeignKey[foreignKeysMap.values().size()])));
        }
      }
 catch (      SQLException e) {
        log.error(e,e);
      }
    }
  }
}