You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andriy Redko (Jira)" <ji...@apache.org> on 2020/09/10 15:55:00 UTC

[jira] [Resolved] (CXF-8227) Failure to comply with JAX-RS spec with ContainerRequestContext and WriterInterceptorContext

     [ https://issues.apache.org/jira/browse/CXF-8227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andriy Redko resolved CXF-8227.
-------------------------------
    Resolution: Fixed

> Failure to comply with JAX-RS spec with ContainerRequestContext and WriterInterceptorContext
> --------------------------------------------------------------------------------------------
>
>                 Key: CXF-8227
>                 URL: https://issues.apache.org/jira/browse/CXF-8227
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.4.0, 3.3.5, 3.2.14
>         Environment: * Linux and or Windows
>  * Java 11.0.6
>  * CXF 3.3.5
>            Reporter: Jorge Cercas
>            Assignee: Andriy Redko
>            Priority: Major
>             Fix For: 3.5.0, 3.3.8, 3.2.15, 3.4.1
>
>
> The Javadoc for the ContainerRequestContext interface says:
>  {{[setProperty|https://docs.oracle.com/javaee/7/api/javax/ws/rs/container/ContainerRequestContext.html#setProperty-java.lang.String-java.lang.Object-](String name, [Object|http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true] object)}}
>  Binds an object to a given property name in the *current request/response exchange context*.
>  {{[getProperty|https://docs.oracle.com/javaee/7/api/javax/ws/rs/container/ContainerRequestContext.html#getProperty-java.lang.String-](String name)}}
>  Returns the property with the given name registered in the *current request/response exchange context*, or {{null}} if there is no property by that name.
> And the Javadoc for the InterceptorContext interface and known sub-interfaces (ReaderInterceptorContext, WriterInterceptorContext) says:
>  {{[setProperty|https://docs.oracle.com/javaee/7/api/javax/ws/rs/ext/InterceptorContext.html#setProperty-java.lang.String-java.lang.Object-](String name, [Object|http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true] object)}}
>  Binds an object to a given property name in the *current request/response exchange context*.
>  {{[getProperty|https://docs.oracle.com/javaee/7/api/javax/ws/rs/ext/InterceptorContext.html#getProperty-java.lang.String-](String name)}}
>  Returns the property with the given name registered in the *current request/response exchange context*, or {{null}} if there is no property by that name.
>   
>  However, given the code below for a resource that does provide an entity, the variable fooBar in the aroundWriteTo method is always null.
> {code:java}
> // code placeholder
> @Provider
> public class InterceptorBug implements ContainerRequestFilter, WriterInterceptor {
>     
>     @Override
>     public void filter(ContainerRequestContext requestContext) throws IOException {
>         requestContext.setProperty("foo.bar", "baz");
>     }
>     @Override
>     public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
>         context.proceed();
>         // 'fooBar' ALWAYS NULL
>         var fooBar = context.getProperty("foo.bar");
>     }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)