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

Unmarshalling Set to TreeSet instead of HashSet

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.1.3
    • 2.2
    • Aegis Databinding
    • None
    • Moderate

    Description

      When using the Aegis databinding, if you are deserializing to a class that has a Set in it, Aegis is currently instantiating the set as a SortedSet. This fails for cases where the objects being added to the set do not implement Comparable, and is undesired in any case.

      The error occurs in CollectionType.java:

          protected Collection<Object> createCollection() {
              Collection values = null;
      
              if (getTypeClass().isAssignableFrom(List.class)) {
                  values = new ArrayList();
              } else if (getTypeClass().isAssignableFrom(SortedSet.class)) {
                  values = new TreeSet();
              } else if (getTypeClass().isAssignableFrom(Set.class)) {
                  values = new HashSet();
              } else if (getTypeClass().isAssignableFrom(Vector.class)) {
                  values = new Vector();
              } else if (getTypeClass().isInterface()) {
                  values = new ArrayList();
              } else {
      ....
      

      If the typeClass is Set, then the second "if" clause evaluates to true since Set is a superclass/superinterface of SortedSet.

      I've got a patch I'll submit and I'll explain the fix.

      Attachments

        1. CXF-1906_patch.txt
          1 kB
          Marcus Christie
        2. CXF-1906_patch.txt
          1 kB
          Marcus Christie

        Activity

          People

            njiang Willem Jiang
            marcuschristie Marcus Christie
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: