IBM Support

PI89955: JAX-RS 2.0: JAVAX.WS.RS.CORE.REQUEST.SELECTVARIANT() RETURNS INCORRECT VALUE

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • JAX-RS 2.0: javax.ws.rs.core.Request.selectVariant() returns
    incorrect
    value
    
    Details:
    A JAX-RS application which uses content negotiation.
    To determine the content it should return they use the method
    javax.ws.rs.core.Request.selectVariant()
    which should return "the variant that best
    matches the request".
    
    On WAS v9 which uses JAX-RS 2.0 the content negotiaton no
    longer works correctly.
    The biggest problem is, that the return value of selectVariant
    differs from the returned HTTP header "Content-Type"
    

Local fix

  • works fine under WAS v8
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server using JAX-RS.                        *
    ****************************************************************
    * PROBLEM DESCRIPTION: The CXF implementation of               *
    *                      javax.ws.rs.core.Request.selectVariant( *
    *                      ) is not correct and the incorrect      *
    *                      Variant is chosen.                      *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    Moving from Apache Wink (JAX-RS 1.1) to
    CXF 3.0.X (JAX-RS 2.0) there are subtle differences
    in the behavior of the javax.ws.rs.core.Request.selectVariant
    method. According to the spec, the returned Variant should be
    one of the Variants passed in to the selectVariant method that
    is the closest match to the request (based on the Accept,
    Accept-Language, and Accept-Encoding headers). This is the
    behavior in Wink, but in CXF the first Variant
    in the passed-in list that matches the request's headers is
    chosen.
    For example, a request with "Accept: a/b, c/d; q=0.5" will
    return a response with "Content-Type: a/b" - assuming that the
    resource method produces a/b and c/d. However, when the user
    calls:
    List<Variant> list = new ArrayList<Variant>();
    Variant v1 = new Variant("a/b", (Locale) null, null);
    Variant v2 = new Variant("c/d", (Locale) null, null);
    Variant v3 = new Variant("not/used", (Locale) null, null);
    list.add(v3);
    list.add(v2);
    list.add(v1);
    assertSame(v1, Request.selectVariant(list));
    the assertion fails. Even though the user prefers a/b over c/d
    by a quality factor of 1 vs 0.5, the selectVariant method
    returns the Variant with c/d. This is because the
    RequestImpl's implementation of the selectVariant method only
    checks the request headers when intersecting the Mime
    (Media)Types.
    See CXF JIRA 7553 for more details:
    https://issues.apache.org/jira/browse/CXF-7553
    

Problem conclusion

  • The CXF code delivered with WebSphere Application Server
    has been changed to match Wink's implementation and  take the
    request header's quality factors into account when determining
    which Variant to return.
    
    The fix for this APAR is currently targeted for inclusion in
    fix pack 9.0.0.7.  Please refer to the Recommended Updates
    page for delivery information:
    http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
    

Temporary fix

Comments

APAR Information

  • APAR number

    PI89955

  • Reported component name

    WEBS APP SERV N

  • Reported component ID

    5724H8800

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2017-11-08

  • Closed date

    2017-11-15

  • Last modified date

    2017-11-15

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    WEBS APP SERV N

  • Fixed component ID

    5724H8800

Applicable component levels

  • R900 PSY

       UP

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.0","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
04 May 2022