jersey
  1. jersey
  2. JERSEY-1267

Implementation needs to be updated to accomodate spec changes based on JAX_RS_SPEC-187 resolution

    Details

    • Type: Task Task
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-m07, 2.0
    • Component/s: None
    • Labels:
      None

      Activity

      Hide
      Pavel Bucek added a comment -

      including migration guide update

      Show
      Pavel Bucek added a comment - including migration guide update
      Hide
      Pavel Bucek added a comment -

      Section 4.2.2 of JAX-RS spec says that when choosing the right MessageBodyWriter to do the job, the runtime needs to order them with the supported media type being the primary key and the generic type being the secondary key. The spec also says app-provided providers take precedence over implementation-provided ones (the spec is ambiguous wrt. whether this is supposed to be the primary key or tertiary key).

      Based on the use-cases we've run into with Jersey, seems the right ordering should instead be based on the following criteria:
      primary) java type more specific
      secondary) media type more specific
      tertiary) app-provided vs. impl-provided

      Representative example (many similar can be found):

      Any POJO provider (e.g. Jackson writer that writes any pojo to application/json) vs. spec-dictated providers - e.g. writer for java.io.InputStream (registered with @Produces("/") according to the spec
      In this scenario, the jackson writer always wins (even if my resource method returns InputStream) as it has more specific media type and is application-provided. Which is obviously wrong.

      I could not find any counter-example that would support the ordering that is currently in the spec.

      See Section 4.2.2. Implementations are REQUIRED to provide a backward compatible flag for those applications that rely on the previous ordering.

      Show
      Pavel Bucek added a comment - Section 4.2.2 of JAX-RS spec says that when choosing the right MessageBodyWriter to do the job, the runtime needs to order them with the supported media type being the primary key and the generic type being the secondary key. The spec also says app-provided providers take precedence over implementation-provided ones (the spec is ambiguous wrt. whether this is supposed to be the primary key or tertiary key). Based on the use-cases we've run into with Jersey, seems the right ordering should instead be based on the following criteria: primary) java type more specific secondary) media type more specific tertiary) app-provided vs. impl-provided Representative example (many similar can be found): Any POJO provider (e.g. Jackson writer that writes any pojo to application/json) vs. spec-dictated providers - e.g. writer for java.io.InputStream (registered with @Produces("/") according to the spec In this scenario, the jackson writer always wins (even if my resource method returns InputStream) as it has more specific media type and is application-provided. Which is obviously wrong. I could not find any counter-example that would support the ordering that is currently in the spec. See Section 4.2.2. Implementations are REQUIRED to provide a backward compatible flag for those applications that rely on the previous ordering.

        People

        • Assignee:
          Pavel Bucek
          Reporter:
          Marek Potociar
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved:

            Time Tracking

            Estimated:
            Original Estimate - 12 hours Original Estimate - 12 hours
            12h
            Remaining:
            Remaining Estimate - 0 minutes
            0m
            Logged:
            Time Spent - 1 day, 1 hour
            1d 1h