Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-1028

MessageBodyWriter Not Respecting media type parameters

XMLWordPrintable

      @GET
      @Produces({"application/json; profile=\"v1\"", "application/json; profile=\"v2\""})
      Response getSomeEntity();
      
      @Singleton
      @Provider
      @Produces("application/json; profile=\"v1\"")
      public class SomeEntityV1MessageBodyWriter implements MessageBodyWriter<SomeEntityPojo> {
      
          @Override
          public void writeTo(SomeEntityPojo someEntity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
              System.out.println("Writing V1");
          }
      
      // SNIP
      }
      
      @Singleton
      @Provider
      @Produces("application/json; profile=\"v2\"")
      public class SomeEntityV2MessageBodyWriter implements MessageBodyWriter<SomeEntityPojo> {
      
          @Override
          public void writeTo(SomeEntityPojo someEntity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
              System.out.println("Writing V2");
          }
      
      // SNIP
      }
      

      Regardless of which media type is provided in the accept header

      application/json; profile="v1"

      or

      application/json; profile="v2"

      only the v1 message body writer seems to get called. It seems to me that the media type parameters are not being taken into consideration when deciding on which message body writer to use.

            patriot1burke@gmail.com Bill Burke (Inactive)
            matthew.madson_jira Matthew Madson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: