Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8227

Failure to comply with JAX-RS spec with ContainerRequestContext and WriterInterceptorContext

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.3.5, 3.2.14, 3.4.0
    • 3.5.0, 3.3.8, 3.4.1
    • JAX-RS
    • None
      • Linux and or Windows
      • Java 11.0.6
      • CXF 3.3.5
    • Unknown

    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

          Activity

            People

              reta Andriy Redko
              bokie Jorge Cercas
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: