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

misleading warning for @XmlType without 'propOrder' element

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.6
    • Fix Version/s: 2.7.8, 2.6.11
    • Component/s: JAXB Databinding
    • Labels:
    • Environment:

      JBoss EAP 6.1.1
      JDK 6u45

    • Estimated Complexity:
      Novice

      Description

      When the @XmlType annotation is used without specifying the propOrder element the following warning is logged:
      WARNING [org.apache.cxf.jaxb.JAXBSchemaInitializer] propOrder in @XmlType doesn't define all schema elements :[]

      This warning is misleading and should not appear in that case.

      Relevant code of org.apache.cxf.jaxb.JAXBSchemaInitializer:

      XmlType xmlTypeAnno = cls.getAnnotation(XmlType.class);
      String[] propertyOrder = null;
      [...]
      if (xmlTypeAnno != null &&  xmlTypeAnno.propOrder().length > 0) {
          propertyOrder = xmlTypeAnno.propOrder();
      }
      [...]
      if (propertyOrder != null && propertyOrder.length == seq.getItems().size()) {
          sortItems(seq, propertyOrder);
      } else if (propertyOrder != null && propertyOrder.length != seq.getItems().size()) {
          LOG.log(Level.WARNING, "propOrder in @XmlType doesn't define all schema elements :" 
              + Arrays.toString(propertyOrder));
      }
      

      If no propOrder element is defined then xmlTypeAnno.propOrder() defaults to

      {""}

      (see http://docs.oracle.com/javaee/7/api/javax/xml/bind/annotation/XmlType.html#propOrder()), so xmlTypeAnno.propOrder().length is 1. Since this is not necessarily equals seq.getItems().size() the mentioned warning is logged.

      Possible patch: the if-elseif-block could be replaced by

      if (propertyOrder != null) {
          if (propertyOrder.length == seq.getItems().size())
          {
              sortItems(seq, propertyOrder);
          } else if (propertyOrder.length > 1 || !propertyOrder[0].isEmpty()) {
              LOG.log(Level.WARNING, "propOrder in @XmlType doesn't define all schema elements :" 
                  + Arrays.toString(propertyOrder));
          }
      }
      

        Attachments

          Activity

            People

            • Assignee:
              dkulp Daniel Kulp
              Reporter:
              lgeidel lars geidel
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: