Program: 137120
Project: 137120
Buggy source:
/** 
 * validate the selected rule .
 */
private void addValidator(){
  setValidator(new ISelectionStatusValidator(){
    public IStatus validate(    Object[] selection){
      IStatus status=new Status(IStatus.OK,CorePlugin.PLUGIN_ID,StringUtils.EMPTY);
      if (selection == null || (selection != null && selection.length > 1)) {
        status=new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,DefaultMessagesImpl.getString("String_Node_Str"));
        return status;
      }
 else {
        for (        Object selectObject : selection) {
          if (selectObject instanceof IFile) {
            IFile file=(IFile)selectObject;
            if (FactoriesUtil.DQRULE.equals(file.getFileExtension())) {
              MatchRuleDefinition matchRuleDef=DQRuleResourceFileHelper.getInstance().findMatchRule(file);
              if (isEmptyRule(matchRuleDef)) {
                status=new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,DefaultMessagesImpl.getString("String_Node_Str"));
                return status;
              }
              Set<String> duplicatedKeys=hasDuplicatedKeys(matchRuleDef);
              if (!duplicatedKeys.isEmpty()) {
                status=new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,DefaultMessagesImpl.getString("String_Node_Str",duplicatedKeys.toString()));
                return status;
              }
              if ((dialogType == MATCHGROUP_TYPE || dialogType == RECORD_MATCHING_TYPE) && T_SWOOSH_ALGORITHM.equals(matchRuleDef.getRecordLinkageAlgorithm())) {
                status=new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,"String_Node_Str");
                return status;
              }
              if (isNeedColumnWarning(matchRuleDef)) {
                String warningMsg=DefaultMessagesImpl.getString("String_Node_Str");
                status=new Status(IStatus.WARNING,CorePlugin.PLUGIN_ID,warningMsg);
              }
            }
          }
        }
      }
      return status;
    }
    /** 
 * check every block keys and match keys, if any key .
 * @param matchRuleDef
 * @return
 */
    private boolean isNeedColumnWarning(    MatchRuleDefinition matchRuleDef){
      boolean needColumnWarning=false;
      if (dialogType != MATCHGROUP_TYPE && dialogType != RECORD_MATCHING_TYPE) {
        for (        BlockKeyDefinition bkd : matchRuleDef.getBlockKeys()) {
          if (hasColumnMatchTheKey(bkd)) {
            needColumnWarning=true;
            break;
          }
        }
      }
      if (dialogType != GENKEY_TYPE) {
        for (        MatchRule rule : matchRuleDef.getMatchRules()) {
          EList<MatchKeyDefinition> matchKeys=rule.getMatchKeys();
          for (          MatchKeyDefinition mkd : matchKeys) {
            if (!hasColumnMatchTheKey(mkd)) {
              needColumnWarning=true;
              break;
            }
          }
          if (needColumnWarning) {
            break;
          }
        }
      }
      return needColumnWarning;
    }
    /** 
 * check if the key's name equals the .
 * @param needColumnWarning
 * @param bkd
 * @return
 */
    private boolean hasColumnMatchTheKey(    KeyDefinition bkd){
      for (      String column : inputColumnNames) {
        if (isColumnNameEqualsWithKey(bkd,column)) {
          return true;
        }
      }
      return false;
    }
    /** 
 * check if the match key or survivor key has .if the user has choose "overwrite",no need to judge then. Judged according to the selected rule type(vsr or tswoosh)
 * @param matchRuleDef
 * @return
 */
    private Set<String> hasDuplicatedKeys(    MatchRuleDefinition matchRuleDef){
      Set<String> duplicatedKeys=new HashSet<String>();
      if (isOverwrite || currentAnaMatchKeys == null) {
        return duplicatedKeys;
      }
      if (RecordMatcherType.simpleVSRMatcher.name().equals(matchRuleDef.getRecordLinkageAlgorithm()) && matchRuleDef.getBlockKeys() != null && currentAnaBlockKeys != null) {
        for (        BlockKeyDefinition blockKey : matchRuleDef.getBlockKeys()) {
          if (blockKey != null && currentAnaBlockKeys.contains(blockKey.getName())) {
            duplicatedKeys.add(blockKey.getName());
          }
        }
      }
      for (      MatchRule rule : matchRuleDef.getMatchRules()) {
        EList<MatchKeyDefinition> matchKeys=rule.getMatchKeys();
        for (        MatchKeyDefinition mkd : matchKeys) {
          if (mkd != null && currentAnaMatchKeys.contains(mkd.getName())) {
            duplicatedKeys.add(mkd.getName());
          }
        }
      }
      return duplicatedKeys;
    }
    /** 
 * DOC yyin Comment method "isEmptyRule".
 * @param matchRuleDef
 * @return
 */
    private boolean isEmptyRule(    MatchRuleDefinition matchRuleDef){
      return (matchRuleDef.getBlockKeys() == null || matchRuleDef.getBlockKeys().size() < 1) && (matchRuleDef.getMatchRules() == null || matchRuleDef.getMatchRules().size() < 1);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * validate the selected rule .
 */
private void addValidator(){
  setValidator(new ISelectionStatusValidator(){
    public IStatus validate(    Object[] selection){
      IStatus status=new Status(IStatus.OK,CorePlugin.PLUGIN_ID,StringUtils.EMPTY);
      if (selection == null || (selection != null && selection.length > 1)) {
        status=new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,DefaultMessagesImpl.getString("String_Node_Str"));
        return status;
      }
 else {
        for (        Object selectObject : selection) {
          if (selectObject instanceof IFile) {
            IFile file=(IFile)selectObject;
            if (FactoriesUtil.DQRULE.equals(file.getFileExtension())) {
              MatchRuleDefinition matchRuleDef=DQRuleResourceFileHelper.getInstance().findMatchRule(file);
              if (isEmptyRule(matchRuleDef)) {
                status=new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,DefaultMessagesImpl.getString("String_Node_Str"));
                return status;
              }
              Set<String> duplicatedKeys=hasDuplicatedKeys(matchRuleDef);
              if (!duplicatedKeys.isEmpty()) {
                status=new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,DefaultMessagesImpl.getString("String_Node_Str",duplicatedKeys.toString()));
                return status;
              }
              if ((dialogType == MATCHGROUP_TYPE || dialogType == RECORD_MATCHING_TYPE) && T_SWOOSH_ALGORITHM.equals(matchRuleDef.getRecordLinkageAlgorithm())) {
                status=new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,"String_Node_Str");
                return status;
              }
              if (isNeedColumnWarning(matchRuleDef)) {
                String warningMsg=DefaultMessagesImpl.getString("String_Node_Str");
                status=new Status(IStatus.WARNING,CorePlugin.PLUGIN_ID,warningMsg);
              }
            }
          }
        }
      }
      return status;
    }
    /** 
 * check every block keys and match keys, if any key .
 * @param matchRuleDef
 * @return
 */
    private boolean isNeedColumnWarning(    MatchRuleDefinition matchRuleDef){
      boolean needColumnWarning=false;
      if (dialogType != MATCHGROUP_TYPE && dialogType != RECORD_MATCHING_TYPE) {
        for (        BlockKeyDefinition bkd : matchRuleDef.getBlockKeys()) {
          if (!hasColumnMatchTheKey(bkd)) {
            needColumnWarning=true;
            break;
          }
        }
      }
      if (dialogType != GENKEY_TYPE) {
        for (        MatchRule rule : matchRuleDef.getMatchRules()) {
          EList<MatchKeyDefinition> matchKeys=rule.getMatchKeys();
          for (          MatchKeyDefinition mkd : matchKeys) {
            if (!hasColumnMatchTheKey(mkd)) {
              needColumnWarning=true;
              break;
            }
          }
          if (needColumnWarning) {
            break;
          }
        }
      }
      return needColumnWarning;
    }
    /** 
 * check if the key's name equals the .
 * @param needColumnWarning
 * @param bkd
 * @return
 */
    private boolean hasColumnMatchTheKey(    KeyDefinition bkd){
      for (      String column : inputColumnNames) {
        if (isColumnNameEqualsWithKey(bkd,column)) {
          return true;
        }
      }
      return false;
    }
    /** 
 * check if the match key or survivor key has .if the user has choose "overwrite",no need to judge then. Judged according to the selected rule type(vsr or tswoosh)
 * @param matchRuleDef
 * @return
 */
    private Set<String> hasDuplicatedKeys(    MatchRuleDefinition matchRuleDef){
      Set<String> duplicatedKeys=new HashSet<String>();
      if (isOverwrite || currentAnaMatchKeys == null) {
        return duplicatedKeys;
      }
      if (RecordMatcherType.simpleVSRMatcher.name().equals(matchRuleDef.getRecordLinkageAlgorithm()) && matchRuleDef.getBlockKeys() != null && currentAnaBlockKeys != null) {
        for (        BlockKeyDefinition blockKey : matchRuleDef.getBlockKeys()) {
          if (blockKey != null && currentAnaBlockKeys.contains(blockKey.getName())) {
            duplicatedKeys.add(blockKey.getName());
          }
        }
      }
      for (      MatchRule rule : matchRuleDef.getMatchRules()) {
        EList<MatchKeyDefinition> matchKeys=rule.getMatchKeys();
        for (        MatchKeyDefinition mkd : matchKeys) {
          if (mkd != null && currentAnaMatchKeys.contains(mkd.getName())) {
            duplicatedKeys.add(mkd.getName());
          }
        }
      }
      return duplicatedKeys;
    }
    /** 
 * DOC yyin Comment method "isEmptyRule".
 * @param matchRuleDef
 * @return
 */
    private boolean isEmptyRule(    MatchRuleDefinition matchRuleDef){
      return (matchRuleDef.getBlockKeys() == null || matchRuleDef.getBlockKeys().size() < 1) && (matchRuleDef.getMatchRules() == null || matchRuleDef.getMatchRules().size() < 1);
    }
  }
);
}