Program: 20582
Project: 20582
Buggy source:
private void processResponses(IMethodModel m,Action action,IDocInfo documentation,String returnName){
  HashMap<String,ResponseModel> responses=new HashMap<String,ResponseModel>();
  String mainResponseCode=DEFAULT_RESPONSE;
  if (config != null) {
    ActionType actionType=action.getType();
    mainResponseCode=config.getResponseCode(actionType);
  }
  ResponseModel mainResponse=new ResponseModel(mainResponseCode,null,returnName);
  responses.put(mainResponseCode,mainResponse);
  IAnnotationModel apiResponse=m.getAnnotation(ResourceVisitor.API_RESPONSE);
  if (apiResponse != null) {
    String code=apiResponse.getValue(ResourceVisitor.CODE);
    String message=apiResponse.getValue(ResourceVisitor.MESSAGE);
    ResponseModel response=new ResponseModel(code,message,returnName);
    responses.put(code,response);
  }
  IAnnotationModel apiResponses=m.getAnnotation(ResourceVisitor.API_RESPONSES);
  if (apiResponses != null) {
    IAnnotationModel[] subAnnotations=apiResponses.getSubAnnotations("String_Node_Str");
    if (subAnnotations != null) {
      for (      IAnnotationModel subAnn : subAnnotations) {
        String code=subAnn.getValue(ResourceVisitor.CODE);
        String message=subAnn.getValue(ResourceVisitor.MESSAGE);
        String adjustedReturnName=returnName;
        String responseQualifiedName=subAnn.getValue(RESPONSE);
        if (responseQualifiedName != null) {
          try {
            Class<?> responseClass=classLoader.loadClass(responseQualifiedName);
            ReflectionType rt=new ReflectionType(responseClass);
            generateXMLSchema(rt,null);
          }
 catch (          ClassNotFoundException e) {
            e.printStackTrace();
          }
          adjustedReturnName=getSimpleName(responseQualifiedName).toLowerCase();
        }
        ResponseModel response=responses.get(code);
        if (response == null) {
          response=new ResponseModel(code,message,adjustedReturnName);
          responses.put(code,response);
        }
 else {
          response.setMessage(message);
          response.setReturnTypeName(adjustedReturnName);
        }
      }
    }
  }
  boolean returnsValue=!m.getReturnedType().getName().toLowerCase().equals("String_Node_Str");
  String[] producesValues=extractMediaTypes(m,PRODUCES,classProduces,returnsValue,null);
  if (producesValues != null) {
    for (    ResponseModel responseModel : responses.values()) {
      responseModel.setProduces(producesValues);
    }
  }
  IAnnotationModel apiOperation=m.getAnnotation(API_OPERATION);
  if (apiOperation != null) {
    String responseContainer=apiOperation.getValue("String_Node_Str");
    String responseQualifiedName=apiOperation.getValue(RESPONSE);
    if (responseQualifiedName != null) {
      try {
        Class<?> responseClass=classLoader.loadClass(responseQualifiedName);
        ReflectionType rt=new ReflectionType(responseClass);
        generateXMLSchema(rt,responseContainer);
      }
 catch (      ClassNotFoundException e) {
        e.printStackTrace();
      }
      String adjustedReturnType=getSimpleName(responseQualifiedName).toLowerCase();
      mainResponse.setReturnTypeName(adjustedReturnType);
    }
  }
  for (  ResponseModel rm : responses.values()) {
    Response response=new Response();
    String description=rm.getMessage();
    if (description == null || description.trim().isEmpty()) {
      description=documentation.getReturnInfo();
    }
    if (description != null && !description.trim().isEmpty()) {
      response.setDescription(description);
    }
    String[] produces=rm.getProduces();
    if (produces != null) {
      String returnTypeName=rm.getReturnTypeName();
      for (      String mediaType : producesValues) {
        mediaType=sanitizeMediaType(mediaType);
        MimeType mimeType=new MimeType();
        if (returnTypeName != null) {
          if (mediaType.contains(XML)) {
            mimeType.setSchema(returnTypeName);
            mimeType.setExample(EXAMPLES_PREFFIX + returnTypeName + XML_FILE_EXT);
            mimeType.setExampleOrigin(EXAMPLES_PREFFIX + returnTypeName + XML_FILE_EXT);
          }
          if (mediaType.contains(JSON)) {
            mimeType.setSchema(returnTypeName + ResourceVisitor.JSONSCHEMA);
            mimeType.setExample(EXAMPLES_PREFFIX + returnTypeName + JSON_FILE_EXT);
            mimeType.setExampleOrigin(EXAMPLES_PREFFIX + returnTypeName + JSON_FILE_EXT);
          }
        }
        mimeType.setType(mediaType);
        response.getBody().put(mediaType,mimeType);
      }
    }
    String code=rm.getCode();
    action.getResponses().put(code,response);
  }
}

Fixed version (ground truth):
private void processResponses(IMethodModel m,Action action,IDocInfo documentation,String returnName){
  HashMap<String,ResponseModel> responses=new HashMap<String,ResponseModel>();
  String mainResponseCode=DEFAULT_RESPONSE;
  if (config != null) {
    ActionType actionType=action.getType();
    mainResponseCode=config.getResponseCode(actionType);
  }
  ResponseModel mainResponse=new ResponseModel(mainResponseCode,null,returnName);
  responses.put(mainResponseCode,mainResponse);
  IAnnotationModel apiResponse=m.getAnnotation(ResourceVisitor.API_RESPONSE);
  if (apiResponse != null) {
    String code=apiResponse.getValue(ResourceVisitor.CODE);
    String message=apiResponse.getValue(ResourceVisitor.MESSAGE);
    ResponseModel response=new ResponseModel(code,message,returnName);
    responses.put(code,response);
  }
  boolean gotResponseSchemesAndExamples=false;
  IAnnotationModel apiResponses=m.getAnnotation(ResourceVisitor.API_RESPONSES);
  if (apiResponses != null) {
    IAnnotationModel[] subAnnotations=apiResponses.getSubAnnotations("String_Node_Str");
    if (subAnnotations != null) {
      for (      IAnnotationModel subAnn : subAnnotations) {
        String code=subAnn.getValue(ResourceVisitor.CODE);
        String message=subAnn.getValue(ResourceVisitor.MESSAGE);
        String adjustedReturnName=returnName;
        String responseQualifiedName=subAnn.getValue(RESPONSE);
        if (responseQualifiedName != null) {
          try {
            Class<?> responseClass=classLoader.loadClass(responseQualifiedName);
            ReflectionType rt=new ReflectionType(responseClass);
            gotResponseSchemesAndExamples|=generateXMLSchema(rt,null);
          }
 catch (          ClassNotFoundException e) {
            e.printStackTrace();
          }
          adjustedReturnName=getSimpleName(responseQualifiedName).toLowerCase();
        }
        ResponseModel response=responses.get(code);
        if (response == null) {
          response=new ResponseModel(code,message,adjustedReturnName);
          responses.put(code,response);
        }
 else {
          response.setMessage(message);
          response.setReturnTypeName(adjustedReturnName);
        }
      }
    }
  }
  boolean returnsValue=!m.getReturnedType().getName().toLowerCase().equals("String_Node_Str");
  String[] producesValues=extractMediaTypes(m,PRODUCES,classProduces,returnsValue,null);
  if (producesValues != null) {
    for (    ResponseModel responseModel : responses.values()) {
      responseModel.setProduces(producesValues);
    }
  }
  IAnnotationModel apiOperation=m.getAnnotation(API_OPERATION);
  if (apiOperation != null) {
    String responseContainer=apiOperation.getValue("String_Node_Str");
    String responseQualifiedName=apiOperation.getValue(RESPONSE);
    if (responseQualifiedName != null) {
      try {
        Class<?> responseClass=classLoader.loadClass(responseQualifiedName);
        ReflectionType rt=new ReflectionType(responseClass);
        gotResponseSchemesAndExamples|=generateXMLSchema(rt,responseContainer);
      }
 catch (      ClassNotFoundException e) {
        e.printStackTrace();
      }
      String adjustedReturnType=getSimpleName(responseQualifiedName).toLowerCase();
      mainResponse.setReturnTypeName(adjustedReturnType);
    }
  }
  for (  ResponseModel rm : responses.values()) {
    Response response=new Response();
    String description=rm.getMessage();
    if (description == null || description.trim().isEmpty()) {
      description=documentation.getReturnInfo();
    }
    if (description != null && !description.trim().isEmpty()) {
      response.setDescription(description);
    }
    String[] produces=rm.getProduces();
    if (produces != null) {
      String returnTypeName=rm.getReturnTypeName();
      for (      String mediaType : producesValues) {
        mediaType=sanitizeMediaType(mediaType);
        MimeType mimeType=new MimeType();
        if (returnTypeName != null) {
          if (mediaType.contains(XML) && gotResponseSchemesAndExamples) {
            mimeType.setSchema(returnTypeName);
            mimeType.setExample(EXAMPLES_PREFFIX + returnTypeName + XML_FILE_EXT);
            mimeType.setExampleOrigin(EXAMPLES_PREFFIX + returnTypeName + XML_FILE_EXT);
          }
          if (mediaType.contains(JSON) && gotResponseSchemesAndExamples) {
            mimeType.setSchema(returnTypeName + ResourceVisitor.JSONSCHEMA);
            mimeType.setExample(EXAMPLES_PREFFIX + returnTypeName + JSON_FILE_EXT);
            mimeType.setExampleOrigin(EXAMPLES_PREFFIX + returnTypeName + JSON_FILE_EXT);
          }
        }
        mimeType.setType(mediaType);
        response.getBody().put(mediaType,mimeType);
      }
    }
    String code=rm.getCode();
    action.getResponses().put(code,response);
  }
}