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

ClientProxyImpl problem with handling @BeanParams with null headers/cookies.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0, 3.0.1
    • 2.7.13, 3.0.2, 3.1
    • None
    • None
    • Unknown

    Description

      Problem occures when my @BeanParam object has String @HeaderParam values that are null.

      On client side inside ClientProxyImpl#getValuesFromBeanParam always returns full Map<String, BeanPair> even when BeanPair has null values.

      ClientProxyImpl.java
      // line 481
      String propertyName = m.getName().substring(3);
      Method getter = bean.getClass().getMethod("get" + propertyName, new Class[]{});
      // Object value is null
      Object value = getter.invoke(bean, new Object[]{});
      String annotationValue = AnnotationUtils.getAnnotationValue(annotation);
      values.put(annotationValue, new BeanPair(value, m.getParameterAnnotations()[0]));
      

      Methods such handleHeaders, handleCookies has useless condition that is
      always true (BeanPair is never null)

      ClientProxyImpl.java
      // line 585
      for (Map.Entry<String, BeanPair> entry : values.entrySet()) {
          if (entry.getValue() != null) {
              headers.add(entry.getKey(), convertParamValue(entry.getValue().getValue(), entry.getValue().getAnns()));
          }
      }
      

      That couses unintended behaviour on server side when server receives BeanParam objects with fields with String value equal to "null".

      I've sent no headers but servers received header with "null" String.

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            michal.p MichaƂ P
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: