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

@Produces("text/event-stream;element-type=text/xml") throws exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 4.5.8.Final
    • 4.5.5.Final
    • jaxrs
    • None

      @Produces("text/event-stream;element-type=text/xml") throws exception.

      From jaikiran, this is regression after RESTEASY-2017:

      Fixed those two tests. Apparently the syntax changed and using @Produces("text/event-stream;element-type=text/xml") will throw in some places, thus requiring:
      @SseElementType(MediaType.TEXT_XML) @Produces(MediaType.SERVER_SENT_EVENTS)
      Is that expected @asoldano ?

      I don't think so, but might be forgetting something. @ronsigal, any clue?

      @asoldano, my guess is that this is an unintentional side-effect of this change https://github.com/resteasy/Resteasy/pull/2361/files#diff-198cf22a0e7c855a4a4b3cf2430f873cL171.
      My guess (based on a quick check of the resteasy code) is that this new code:
       
      Arrays.asList(mediaTypes).contains(MediaType.SERVER_SENT_EVENTS_TYPE)

      is no longer satisfied, due to the fact that the MediaType.equals implementation also takes into account the parameters map for equality check. So the constant MediaType.SERVER_SENT_EVENTS_TYPE which doesn't have any parameters isn't considered equal to a MediaType.SERVER_SENT_EVENTS_TYPE which is parsed out of the text/event-stream;element-type=text/xml which will have a parameters map populated with the element-type key/value pair.

      For a similar use case for equality check, I had to write something like this in Quarkus a while back https://github.com/quarkusio/quarkus/blob/master/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java#L541. I guess, at a minimum, something like that probably needs to be done in RestEasy too, since this change looks like an regression (not just in Quarkus but in RestEasy core itself).

            rhn-engineering-ema Jim Ma
            rhn-engineering-ema Jim Ma
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: