[jira] [Commented] (CXF-8408) Response.getLocation() returns null after update from CXF 3.3.6 to 3.4.1

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[jira] [Commented] (CXF-8408) Response.getLocation() returns null after update from CXF 3.3.6 to 3.4.1

Colm O hEigeartaigh (Jira)

    [ https://issues.apache.org/jira/browse/CXF-8408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17263459#comment-17263459 ]

Andy McCright commented on CXF-8408:

Hi [~hohwille], [~reta],

The 3.3.6 behavior was wrong from the start.  I made the original change to put the request's URI in the Response's location property when I implemented MicroProfile Rest Client 1.1[1], but this change violated the JAX-RS specification so I reverted that change in a subsequent change[2].

Per the JAX-RS TCK [3 and 4], the Response's location property corresponds to the HTTP response's `Location` header - so it should not be used for the request URI - it should only be non-null if the HTTP response contains a non-null value in the `Location` header.

I certainly see the value of getting the request URI from the Response object.  Perhaps a solution here would be to add a new getRequestUri() method to ResponseImpl that would return the request URI?  

Hope this helps!

[1] https://github.com/apache/cxf/pull/396
[2] https://github.com/apache/cxf/pull/697
[3] https://github.com/eclipse-ee4j/jakartaee-tck/blob/c457c40af61d307b0dea0e0489fed7ab4c3e8490/src/com/sun/ts/tests/jaxrs/ee/rs/core/response/JAXRSClient.java#L766
[4] https://github.com/eclipse-ee4j/jakartaee-tck/blob/c457c40af61d307b0dea0e0489fed7ab4c3e8490/src/com/sun/ts/tests/jaxrs/ee/rs/core/response/JAXRSClient.java#L783

> Response.getLocation() returns null after update from CXF 3.3.6 to 3.4.1
> ------------------------------------------------------------------------
>                 Key: CXF-8408
>                 URL: https://issues.apache.org/jira/browse/CXF-8408
>             Project: CXF
>          Issue Type: Improvement
>    Affects Versions: 3.4.1
>            Reporter: Jörg Hohwiller
>            Priority: Major
> javax.ws.rs.core.Response.getLocation() used to return the URL of the service invoked. We used this information to enhance the error handling via a custom org.apache.cxf.jaxrs.client.ResponseExceptionMapper since CXF lacks to provide contextual information in error scenarios making it hard to use in productive environments when service client invocations fail without contextual information available.
> After we now updated from 3.3.6 to 3.4.1 one of our tests failed with an NPE since response.getLocation() now returns null instead of the correct URL and we were doing url.toString() on that without checking for null.
> I am working on ugly workarounds (casting to ResponseImpl and getting the Conduit to retrieve at least the base URL) but it would be great if CXF could fix this regression bug at the root.
> [https://github.com/devonfw/devon4j/pull/310/]

This message was sent by Atlassian Jira