Program: 20523
Project: 20523
Buggy source:
private void writeMethod(RamlResourceMethod method,List<RamlSupportedAnnotation> supportedAnnotation) throws IOException {
  writer.appendLine(format("String_Node_Str",method.getHttpMethod()));
  writer.indent();
  annotationInstanceEmitter.emitAnnotations(method);
  Optional<String> description=method.getDescription();
  if (description.isPresent() && !description.get().isEmpty()) {
    writeDescription(description.get());
  }
  if (!method.getConsumedMediaTypes().isEmpty() && (method.getConsumedType().isPresent() || !method.getFormParameters().isEmpty())) {
    writer.appendLine("String_Node_Str");
    writer.indent();
    for (    RamlMediaType ramlMediaType : method.getConsumedMediaTypes()) {
      if (ramlMediaType.toStringRepresentation().equals("String_Node_Str")) {
        writer.appendLine(ramlMediaType.toStringRepresentation());
        writer.indent();
        writeFormParam(method);
        writer.outdent();
      }
 else {
        Type type=method.getConsumedType().get().getType();
        TypeHandler typeHandler=pickTypeHandler(method,ramlMediaType,type);
        typeHandler.writeType(typeRegistry,writer,ramlMediaType,method,method.getConsumedType().get());
      }
    }
    writer.outdent();
  }
  ResponseHandler handler=pickResponseHandler(method);
  TypeSelector selector=new TypeSelector(){
    @Override public TypeHandler pickTypeWriter(    RamlResourceMethod method,    RamlMediaType producedMediaType){
      return pickTypeHandler(method,producedMediaType,method.getProducedType().get().getType());
    }
  }
;
  if (!method.getProducedMediaTypes().isEmpty()) {
    writer.appendLine("String_Node_Str");
    writer.indent();
    handler.writeResponses(typeRegistry,writer,method,selector);
    writer.outdent();
  }
  if (!method.getHeaderParameters().isEmpty()) {
    writeHeaderParameters(method.getHeaderParameters());
  }
  if (!method.getQueryParameters().isEmpty()) {
    writeQueryParameters(method.getQueryParameters());
  }
  writer.outdent();
}

Fixed version (ground truth):
private void writeMethod(RamlResourceMethod method,List<RamlSupportedAnnotation> supportedAnnotation) throws IOException {
  writer.appendLine(format("String_Node_Str",method.getHttpMethod()));
  writer.indent();
  annotationInstanceEmitter.emitAnnotations(method);
  Optional<String> description=method.getDescription();
  if (description.isPresent() && !description.get().isEmpty()) {
    writeDescription(description.get());
  }
  if (!method.getConsumedMediaTypes().isEmpty() && (method.getConsumedType().isPresent() || !method.getFormParameters().isEmpty())) {
    writer.appendLine("String_Node_Str");
    writer.indent();
    for (    RamlMediaType ramlMediaType : method.getConsumedMediaTypes()) {
      if (ramlMediaType.toStringRepresentation().equals("String_Node_Str")) {
        writer.appendLine(ramlMediaType.toStringRepresentation() + "String_Node_Str");
        writer.indent();
        writeFormParam(method);
        writer.outdent();
      }
 else {
        Type type=method.getConsumedType().get().getType();
        TypeHandler typeHandler=pickTypeHandler(method,ramlMediaType,type);
        typeHandler.writeType(typeRegistry,writer,ramlMediaType,method,method.getConsumedType().get());
      }
    }
    writer.outdent();
  }
  ResponseHandler handler=pickResponseHandler(method);
  TypeSelector selector=new TypeSelector(){
    @Override public TypeHandler pickTypeWriter(    RamlResourceMethod method,    RamlMediaType producedMediaType){
      return pickTypeHandler(method,producedMediaType,method.getProducedType().get().getType());
    }
  }
;
  if (!method.getProducedMediaTypes().isEmpty()) {
    writer.appendLine("String_Node_Str");
    writer.indent();
    handler.writeResponses(typeRegistry,writer,method,selector);
    writer.outdent();
  }
  if (!method.getHeaderParameters().isEmpty()) {
    writeHeaderParameters(method.getHeaderParameters());
  }
  if (!method.getQueryParameters().isEmpty()) {
    writeQueryParameters(method.getQueryParameters());
  }
  writer.outdent();
}