Program: 2499
Project: 2499
Buggy source:
/** 
 * {@inheritDoc}
 */
public void validate(ModuleContext context,ModelObject mobj,ScribbleLogger logger){
  Module elem=(Module)mobj;
  if (elem.getFullyQualifiedName() == null) {
    logger.error(ValidationMessages.getMessage("String_Node_Str"),mobj);
  }
  for (  ImportDecl imp : elem.getImports()) {
    ValidationRule rule=ValidationRuleFactory.getValidationRule(imp);
    if (rule != null) {
      rule.validate(context,imp,logger);
    }
  }
  for (  PayloadTypeDecl ptd : elem.getPayloadTypeDeclarations()) {
    ValidationRule rule=ValidationRuleFactory.getValidationRule(ptd);
    if (rule != null) {
      rule.validate(context,ptd,logger);
    }
  }
  boolean f_global=true;
  String localRole=null;
  if (context.getResource() != null) {
    int pos=context.getResource().getName().indexOf('@');
    if (pos != -1) {
      f_global=false;
      localRole=context.getResource().getName().substring(pos + 1,context.getResource().getName().length() - 4);
    }
  }
  for (int i=0; i < elem.getProtocols().size(); i++) {
    ProtocolDecl protocol=elem.getProtocols().get(i);
    if (context.getResource() != null) {
      if (protocol instanceof LProtocolDecl) {
        Role role=((LProtocolDecl)protocol).getLocalRole();
        if (f_global) {
          logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),role.getName()),protocol);
        }
 else         if (!role.getName().equals(localRole)) {
          logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),role.getName(),localRole),protocol);
        }
      }
 else       if (!f_global) {
        logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),localRole),protocol);
      }
    }
    ValidationRule rule=ValidationRuleFactory.getValidationRule(protocol);
    if (rule != null) {
      rule.validate(context,protocol,logger);
    }
  }
  if (context.getResource() != null && context.getResource().getPath() != null) {
    String fileName=elem.getFullyQualifiedName().getLastPart();
    if (localRole != null) {
      fileName+="String_Node_Str" + localRole;
    }
    fileName+="String_Node_Str";
    String fileName2=java.io.File.separator + fileName;
    if (!context.getResource().getPath().equals(fileName) && !context.getResource().getPath().endsWith(fileName2)) {
      logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),elem.getFullyQualifiedName().getName(),elem.getFullyQualifiedName().getLastPart() + "String_Node_Str"),mobj);
    }
  }
  java.util.List<String> moduleNames=new java.util.ArrayList<String>();
  if (elem.getFullyQualifiedName() != null) {
    moduleNames.add(elem.getFullyQualifiedName().getLastPart());
  }
  for (  ImportDecl imp : elem.getImports()) {
    if (imp.getMemberName() == null) {
      String declName=imp.getDeclarationName();
      if (moduleNames.contains(declName)) {
        logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),declName),mobj);
      }
 else {
        moduleNames.add(declName);
      }
    }
  }
  java.util.List<String> memberNames=new java.util.ArrayList<String>();
  for (  ImportDecl imp : elem.getImports()) {
    if (imp.getMemberName() != null) {
      String declName=imp.getDeclarationName();
      if (memberNames.contains(declName)) {
        logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),declName),imp);
      }
 else {
        memberNames.add(declName);
      }
    }
  }
  for (  PayloadTypeDecl plt : elem.getPayloadTypeDeclarations()) {
    if (memberNames.contains(plt.getAlias())) {
      logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),plt.getAlias()),plt);
    }
 else {
      memberNames.add(plt.getAlias());
    }
  }
  for (  ProtocolDecl pd : elem.getProtocols()) {
    if (memberNames.contains(pd.getName())) {
      logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),pd.getName()),pd);
    }
 else {
      memberNames.add(pd.getName());
    }
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public void validate(ModuleContext context,ModelObject mobj,ScribbleLogger logger){
  Module elem=(Module)mobj;
  if (elem.getFullyQualifiedName() == null) {
    logger.error(ValidationMessages.getMessage("String_Node_Str"),mobj);
  }
  for (  ImportDecl imp : elem.getImports()) {
    ValidationRule rule=ValidationRuleFactory.getValidationRule(imp);
    if (rule != null) {
      rule.validate(context,imp,logger);
    }
  }
  for (  PayloadTypeDecl ptd : elem.getPayloadTypeDeclarations()) {
    ValidationRule rule=ValidationRuleFactory.getValidationRule(ptd);
    if (rule != null) {
      rule.validate(context,ptd,logger);
    }
  }
  boolean f_global=true;
  String localRole=null;
  if (context.getResource() != null) {
    int pos=context.getResource().getName().indexOf('@');
    if (pos != -1) {
      f_global=false;
      localRole=context.getResource().getName().substring(pos + 1,context.getResource().getName().length() - 4);
    }
  }
  for (int i=0; i < elem.getProtocols().size(); i++) {
    ProtocolDecl protocol=elem.getProtocols().get(i);
    if (context.getResource() != null) {
      if (protocol instanceof LProtocolDecl) {
        Role role=((LProtocolDecl)protocol).getLocalRole();
        if (f_global) {
          logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),role.getName()),protocol);
        }
 else         if (!role.getName().equals(localRole)) {
          logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),role.getName(),localRole),protocol);
        }
      }
 else       if (!f_global) {
        logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),localRole),protocol);
      }
    }
    ValidationRule rule=ValidationRuleFactory.getValidationRule(protocol);
    if (rule != null) {
      rule.validate(context,protocol,logger);
    }
  }
  if (context.getResource() != null && context.getResource().getPath() != null) {
    String filepath=elem.getFullyQualifiedName().getName().replace('.',java.io.File.separatorChar);
    if (localRole != null) {
      filepath+="String_Node_Str" + localRole;
    }
    filepath+="String_Node_Str";
    if (!context.getResource().getPath().equals(filepath)) {
      logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),elem.getFullyQualifiedName().getName(),filepath),mobj);
    }
  }
  java.util.List<String> moduleNames=new java.util.ArrayList<String>();
  if (elem.getFullyQualifiedName() != null) {
    moduleNames.add(elem.getFullyQualifiedName().getLastPart());
  }
  for (  ImportDecl imp : elem.getImports()) {
    if (imp.getMemberName() == null) {
      String declName=imp.getDeclarationName();
      if (moduleNames.contains(declName)) {
        logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),declName),mobj);
      }
 else {
        moduleNames.add(declName);
      }
    }
  }
  java.util.List<String> memberNames=new java.util.ArrayList<String>();
  for (  ImportDecl imp : elem.getImports()) {
    if (imp.getMemberName() != null) {
      String declName=imp.getDeclarationName();
      if (memberNames.contains(declName)) {
        logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),declName),imp);
      }
 else {
        memberNames.add(declName);
      }
    }
  }
  for (  PayloadTypeDecl plt : elem.getPayloadTypeDeclarations()) {
    if (memberNames.contains(plt.getAlias())) {
      logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),plt.getAlias()),plt);
    }
 else {
      memberNames.add(plt.getAlias());
    }
  }
  for (  ProtocolDecl pd : elem.getProtocols()) {
    if (memberNames.contains(pd.getName())) {
      logger.error(MessageFormat.format(ValidationMessages.getMessage("String_Node_Str"),pd.getName()),pd);
    }
 else {
      memberNames.add(pd.getName());
    }
  }
}