Program: 96815
Project: 96815
Buggy source:
@GET public Response getResponse(){
  ResponseBuilder builder=Response.noContent();
  try {
    QueryFactory factory=OrcsApplication.getOrcsApi().getQueryFactory();
    QueryBuilder queryBuilder=factory.fromBranch(branchUuid).andUuid(artifactUuid);
    if (transactionId.isValid()) {
      queryBuilder.fromTransaction(transactionId);
    }
    ArtifactReadable exactlyOne=queryBuilder.getResults().getExactlyOne();
    Optional<? extends AttributeReadable<Object>> item=Iterables.tryFind(exactlyOne.getAttributes(),new Predicate<AttributeReadable<Object>>(){
      @Override public boolean apply(      AttributeReadable<Object> attribute){
        return attribute.getLocalId() == attrId;
      }
    }
);
    if (item.isPresent()) {
      Object value=item.get();
      if (value instanceof AttributeReadable<?>) {
        builder=Response.ok();
        AttributeReadable<?> attribute=(AttributeReadable<?>)value;
        String mediaType=OrcsApplication.getOrcsApi().getOrcsTypes().getAttributeTypes().getMediaType(attribute.getAttributeType());
        String fileExtension=OrcsApplication.getOrcsApi().getOrcsTypes().getAttributeTypes().getFileTypeExtension(attribute.getAttributeType());
        if (mediaType.isEmpty() || mediaType.startsWith("String_Node_Str")) {
          builder.entity(attribute.getDisplayableString());
        }
 else {
          ResultSet<? extends AttributeReadable<Object>> results=exactlyOne.getAttributes(CoreAttributeTypes.Extension);
          AttributeReadable<Object> extension=results.getOneOrNull();
          if (extension != null) {
            fileExtension=extension.getDisplayableString();
          }
          Object content=attribute.getValue();
          builder.entity(content);
          builder.header("String_Node_Str",mediaType);
          String filename=URLEncoder.encode(exactlyOne.getName() + "String_Node_Str" + fileExtension,"String_Node_Str");
          builder.header("String_Node_Str","String_Node_Str" + filename);
        }
      }
    }
 else {
      builder=Response.status(Status.NOT_FOUND);
    }
  }
 catch (  Exception ex) {
    throw new WebApplicationException(ex);
  }
  return builder.build();
}

Fixed version (ground truth):
@GET public Response getResponse(){
  ResponseBuilder builder=Response.noContent();
  try {
    QueryFactory factory=OrcsApplication.getOrcsApi().getQueryFactory();
    QueryBuilder queryBuilder=factory.fromBranch(branchUuid).andUuid(artifactUuid);
    if (transactionId.isValid()) {
      queryBuilder.fromTransaction(transactionId);
    }
    ArtifactReadable exactlyOne=queryBuilder.getResults().getExactlyOne();
    Optional<? extends AttributeReadable<Object>> item=Iterables.tryFind(exactlyOne.getAttributes(),new Predicate<AttributeReadable<Object>>(){
      @Override public boolean apply(      AttributeReadable<Object> attribute){
        return attribute.getLocalId() == attrId;
      }
    }
);
    if (item.isPresent()) {
      Object value=item.get();
      if (value instanceof AttributeReadable<?>) {
        builder=Response.ok();
        AttributeReadable<?> attribute=(AttributeReadable<?>)value;
        String mediaType=OrcsApplication.getOrcsApi().getOrcsTypes().getAttributeTypes().getMediaType(attribute.getAttributeType());
        String fileExtension=OrcsApplication.getOrcsApi().getOrcsTypes().getAttributeTypes().getFileTypeExtension(attribute.getAttributeType());
        if (mediaType.isEmpty() || mediaType.startsWith("String_Node_Str") || textOut) {
          builder.entity(attribute.getDisplayableString());
          builder.header("String_Node_Str",MediaType.PLAIN_TEXT_UTF_8);
        }
 else {
          ResultSet<? extends AttributeReadable<Object>> results=exactlyOne.getAttributes(CoreAttributeTypes.Extension);
          AttributeReadable<Object> extension=results.getOneOrNull();
          if (extension != null) {
            fileExtension=extension.getDisplayableString();
          }
          Object content=attribute.getValue();
          builder.entity(content);
          builder.header("String_Node_Str",mediaType);
          String filename=URLEncoder.encode(exactlyOne.getName() + "String_Node_Str" + fileExtension,"String_Node_Str");
          builder.header("String_Node_Str","String_Node_Str" + filename);
        }
      }
    }
 else {
      builder=Response.status(Status.NOT_FOUND);
    }
  }
 catch (  Exception ex) {
    throw new WebApplicationException(ex);
  }
  return builder.build();
}