Details
Description
The Javadoc for the ContainerRequestContext interface says:
setProperty(String name, Object object)
Binds an object to a given property name in the current request/response exchange context.
getProperty(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(String name, Object object)
Binds an object to a given property name in the current request/response exchange context.
getProperty(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 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"); } }
Attachments
Issue Links
- links to