Program: 136482
Project: 136482
Buggy source:
public static SurvivorShipAlgorithmParams createSurvivorShipAlgorithmParams(AnalysisMatchRecordGrouping analysisMatchRecordGrouping,RecordMatchingIndicator recordMatchingIndicator,Map<MetadataColumn,String> columnMap){
  SurvivorShipAlgorithmParams survivorShipAlgorithmParams=new SurvivorShipAlgorithmParams();
  List<SurvivorshipKeyDefinition> survivorshipKeyDefs=recordMatchingIndicator.getBuiltInMatchRuleDefinition().getSurvivorshipKeys();
  List<SurvivorshipFunction> survFunctions=new ArrayList<SurvivorshipFunction>();
  for (  SurvivorshipKeyDefinition survDef : survivorshipKeyDefs) {
    SurvivorshipFunction func=survivorShipAlgorithmParams.new SurvivorshipFunction();
    func.setSurvivorShipKey(survDef.getName());
    func.setParameter(survDef.getFunction().getAlgorithmParameters());
    func.setSurvivorShipAlgoEnum(SurvivorShipAlgorithmEnum.getTypeBySavedValue(survDef.getFunction().getAlgorithmType()));
    survFunctions.add(func);
  }
  survivorShipAlgorithmParams.setSurviorShipAlgos(survFunctions.toArray(new SurvivorshipFunction[survivorshipKeyDefs.size()]));
  List<DefaultSurvivorshipDefinition> defSurvDefs=recordMatchingIndicator.getBuiltInMatchRuleDefinition().getDefaultSurvivorshipDefinitions();
  Map<Integer,SurvivorshipFunction> defaultSurvRules=new HashMap<Integer,SurvivorshipFunction>();
  for (  MetadataColumn metaColumn : columnMap.keySet()) {
    String dataTypeName=metaColumn.getTalendType();
    for (    DefaultSurvivorshipDefinition defSurvDef : defSurvDefs) {
      if (StringUtils.equals(dataTypeName,"String_Node_Str" + defSurvDef.getDataType())) {
        putNewSurvFunc(columnMap,survivorShipAlgorithmParams,defaultSurvRules,metaColumn,defSurvDef);
        break;
      }
 else       if (StringUtils.equals(defSurvDef.getDataType(),"String_Node_Str") && JavaTypesManager.isNumber(dataTypeName)) {
        putNewSurvFunc(columnMap,survivorShipAlgorithmParams,defaultSurvRules,metaColumn,defSurvDef);
        break;
      }
    }
  }
  survivorShipAlgorithmParams.setDefaultSurviorshipRules(defaultSurvRules);
  CombinedRecordMatcher combinedRecordMatcher=analysisMatchRecordGrouping.getCombinedRecordMatcher();
  survivorShipAlgorithmParams.setRecordMatcher(combinedRecordMatcher);
  Map<IRecordMatcher,SurvivorshipFunction[]> survAlgos=new HashMap<IRecordMatcher,SurvivorshipFunction[]>();
  SurvivorshipFunction[] survFuncs=survivorShipAlgorithmParams.getSurviorShipAlgos();
  Map<Integer,SurvivorshipFunction> colIdx2DefaultSurvFunc=survivorShipAlgorithmParams.getDefaultSurviorshipRules();
  int matchRuleIdx=-1;
  List<List<Map<String,String>>> multiRules=analysisMatchRecordGrouping.getMultiMatchRules();
  for (  List<Map<String,String>> matchrule : multiRules) {
    matchRuleIdx++;
    if (matchrule == null) {
      continue;
    }
    SurvivorshipFunction[] surFuncsInMatcher=new SurvivorshipFunction[matchrule.size()];
    int idx=0;
    for (    Map<String,String> mkDef : matchrule) {
      String matcherType=mkDef.get(IRecordGrouping.MATCHING_TYPE);
      if (AttributeMatcherType.DUMMY.name().equals(matcherType)) {
        surFuncsInMatcher[idx]=colIdx2DefaultSurvFunc.get(Integer.valueOf(mkDef.get(IRecordGrouping.COLUMN_IDX)));
        if (surFuncsInMatcher[idx] == null) {
          surFuncsInMatcher[idx]=survivorShipAlgorithmParams.new SurvivorshipFunction();
          surFuncsInMatcher[idx].setSurvivorShipAlgoEnum(SurvivorShipAlgorithmEnum.CONCATENATE);
          surFuncsInMatcher[idx].setParameter(SurvivorshipUtils.DEFAULT_CONCATENATE_PARAMETER);
        }
      }
 else {
        for (        SurvivorshipFunction survFunc : survFuncs) {
          String keyName=mkDef.get(IRecordGrouping.MATCH_KEY_NAME);
          if (keyName.equals(survFunc.getSurvivorShipKey())) {
            surFuncsInMatcher[idx]=survFunc;
            break;
          }
        }
      }
      idx++;
    }
    survAlgos.put(combinedRecordMatcher.getMatchers().get(matchRuleIdx),surFuncsInMatcher);
  }
  survivorShipAlgorithmParams.setSurvivorshipAlgosMap(survAlgos);
  return survivorShipAlgorithmParams;
}

Fixed version (ground truth):
/** 
 * DOC zshen Comment method "createSurvivorShipAlgorithmParams". Same with   {@link SurvivorshipUtils#createSurvivorShipAlgorithmParams(AnalysisMatchRecordGrouping,List,List,Map,Map)} sothat any modify need to synchronization them with same time
 * @param analysisMatchRecordGrouping
 * @param recordMatchingIndicator
 * @param columnMap
 * @return
 */
public static SurvivorShipAlgorithmParams createSurvivorShipAlgorithmParams(AnalysisMatchRecordGrouping analysisMatchRecordGrouping,RecordMatchingIndicator recordMatchingIndicator,Map<MetadataColumn,String> columnMap){
  SurvivorShipAlgorithmParams survivorShipAlgorithmParams=new SurvivorShipAlgorithmParams();
  List<SurvivorshipKeyDefinition> survivorshipKeyDefs=recordMatchingIndicator.getBuiltInMatchRuleDefinition().getSurvivorshipKeys();
  List<SurvivorshipFunction> survFunctions=new ArrayList<SurvivorshipFunction>();
  for (  SurvivorshipKeyDefinition survDef : survivorshipKeyDefs) {
    SurvivorshipFunction func=survivorShipAlgorithmParams.new SurvivorshipFunction();
    func.setSurvivorShipKey(survDef.getName());
    func.setParameter(survDef.getFunction().getAlgorithmParameters());
    func.setSurvivorShipAlgoEnum(SurvivorShipAlgorithmEnum.getTypeBySavedValue(survDef.getFunction().getAlgorithmType()));
    survFunctions.add(func);
  }
  survivorShipAlgorithmParams.setSurviorShipAlgos(survFunctions.toArray(new SurvivorshipFunction[survivorshipKeyDefs.size()]));
  List<DefaultSurvivorshipDefinition> defSurvDefs=recordMatchingIndicator.getBuiltInMatchRuleDefinition().getDefaultSurvivorshipDefinitions();
  Map<Integer,SurvivorshipFunction> defaultSurvRules=new HashMap<Integer,SurvivorshipFunction>();
  for (  MetadataColumn metaColumn : columnMap.keySet()) {
    String dataTypeName=metaColumn.getTalendType();
    for (    DefaultSurvivorshipDefinition defSurvDef : defSurvDefs) {
      if (StringUtils.equals(dataTypeName,"String_Node_Str" + defSurvDef.getDataType()) || StringUtils.equals(defSurvDef.getDataType(),"String_Node_Str") && JavaTypesManager.isNumber(dataTypeName)) {
        putNewSurvFunc(columnMap,survivorShipAlgorithmParams,defaultSurvRules,metaColumn,defSurvDef);
        break;
      }
    }
  }
  survivorShipAlgorithmParams.setDefaultSurviorshipRules(defaultSurvRules);
  CombinedRecordMatcher combinedRecordMatcher=analysisMatchRecordGrouping.getCombinedRecordMatcher();
  survivorShipAlgorithmParams.setRecordMatcher(combinedRecordMatcher);
  Map<IRecordMatcher,SurvivorshipFunction[]> survAlgos=new HashMap<IRecordMatcher,SurvivorshipFunction[]>();
  SurvivorshipFunction[] survFuncs=survivorShipAlgorithmParams.getSurviorShipAlgos();
  Map<Integer,SurvivorshipFunction> colIdx2DefaultSurvFunc=survivorShipAlgorithmParams.getDefaultSurviorshipRules();
  int matchRuleIdx=-1;
  List<List<Map<String,String>>> multiRules=analysisMatchRecordGrouping.getMultiMatchRules();
  for (  List<Map<String,String>> matchrule : multiRules) {
    matchRuleIdx++;
    if (matchrule == null) {
      continue;
    }
    SurvivorshipFunction[] surFuncsInMatcher=new SurvivorshipFunction[matchrule.size()];
    int idx=0;
    for (    Map<String,String> mkDef : matchrule) {
      String matcherType=mkDef.get(IRecordGrouping.MATCHING_TYPE);
      if (AttributeMatcherType.DUMMY.name().equalsIgnoreCase(matcherType)) {
        surFuncsInMatcher[idx]=colIdx2DefaultSurvFunc.get(Integer.valueOf(mkDef.get(IRecordGrouping.COLUMN_IDX)));
        if (surFuncsInMatcher[idx] == null) {
          surFuncsInMatcher[idx]=survivorShipAlgorithmParams.new SurvivorshipFunction();
          surFuncsInMatcher[idx].setSurvivorShipAlgoEnum(SurvivorShipAlgorithmEnum.CONCATENATE);
          surFuncsInMatcher[idx].setParameter(SurvivorshipUtils.DEFAULT_CONCATENATE_PARAMETER);
        }
      }
 else {
        for (        SurvivorshipFunction survFunc : survFuncs) {
          String keyName=mkDef.get(IRecordGrouping.MATCH_KEY_NAME);
          if (keyName.equals(survFunc.getSurvivorShipKey())) {
            surFuncsInMatcher[idx]=survFunc;
            break;
          }
        }
      }
      idx++;
    }
    survAlgos.put(combinedRecordMatcher.getMatchers().get(matchRuleIdx),surFuncsInMatcher);
  }
  survivorShipAlgorithmParams.setSurvivorshipAlgosMap(survAlgos);
  return survivorShipAlgorithmParams;
}