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

JAX-RS @FormParam parameters are not updated when form content is modified

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2.6
    • Fix Version/s: 3.2.7, 3.3.0
    • Component/s: JAX-RS
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      The JAX-RS community noticed a difference in behavior between CXF and Jersey/RESTEasy where form data in the HTTP body is modified prior to invoking the resource method.  There are two differences noted:

      1) CXF does not invoke a MessageBodyReader (or any ReaderInterceptors) when there is no entity parameter.  I believe that this is proper behavior - or at least an appropriate optimization since there is no parameter, why bother creating one with a MBR (and it's associated ReaderInterceptors)?  

      2) When the resource method contains both a Form parameter (entity) and a parameter annotated with `@FormParam`, and a Filter or interceptor, etc. has modified the content of of the HTTP body, the value injected for the `@FormParam` parameter does not reflect those modifications, but the Form entity parameter does.  This seems inconsistent, and (IMO) violates the spirit of the spec - note that there is no TCK test for this case, so CXF is still compliant - but it differs from other implementations.  Here is an example:

       

       

      @Provider
      public class FormReaderInterceptor implements ReaderInterceptor {
          private static final Logger LOG = LogUtils.getL7dLogger(FormReaderInterceptor.class);
          @Override
          public Object aroundReadFrom(ReaderInterceptorContext ctx) throws IOException, WebApplicationException {
              BufferedReader br = new BufferedReader(new InputStreamReader(ctx.getInputStream()));
              String line;
              while ((line = br.readLine()) != null) {
                  LOG.info("readLine: " + line);
              }
              ByteArrayInputStream bais = new ByteArrayInputStream("value=MODIFIED".getBytes());
      
              ctx.setInputStream(bais);
              return ctx.proceed();
          }
      }
      

       

          @POST
      
          public Response processForm(@FormParam("value") String value, Form form) {...
       

       

      If the HTTP request body contains "value=ORIGINAL", then when CXF invokes the processForm method, it will pass "ORIGINAL" to the String value, but will pass a Form object that contains a MultivaluedMap with entry "value=MODIFIED".  To be consistent with Jersey and RESTEasy, CXF should inject MODIFIED as the String value.

       

      See JAX-RS API Issue 659 for more details.

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                andymc Andy McCright
                Reporter:
                andymc Andy McCright
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: