Uploaded image for project: 'UIMA'
  1. UIMA
  2. UIMA-6112

JSON serializer produces repeated duplicate types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • 2.7.0SDK, 2.8.0SDK, 2.8.1SDK, 2.9.0SDK
    • None
    • UIMA
    • None

    Description

      The JSON produces using the JsonCasSerializer contains errors.

      Tracked it back and it looks like a comparator is used to sort an array

      uimaj-core : org.apache.uima.cas.impl.CasSerializerSupport.sortedUsedTypes

      in method:

      getSortedUsedTypes() used Arrays.sort(TypeImpl[], Comparator<TypeImpl>)

      Used Comparator:

      uimaj-core : org.apache.uima.cas.impl.CasSerializerSupport.COMPARATOR_SHORT_TYPENAME (non-public)

        final static Comparator<TypeImpl> COMPARATOR_SHORT_TYPENAME = new Comparator<TypeImpl>() {

          public int compare(TypeImpl object1, TypeImpl object2)

      {       *return* object1.getShortName().compareTo(object2.getShortName());     }

        };

       

      and then the default type comparison is used for a binary search

      org.apache.uima.cas.impl.TypeImpl implements Comparable<TypeImp>

        public int compareTo(TypeImpl t) {

          if (this == t)

      {       *return* 0;     }

          return (this.code < t.code) ? -1 : 1;

        }

       

      In uima-json : org.apache.uima.json.JsonCasSerializer.collectUsedSubTypes()

      the Arrays.binarySearch(TypeImpl[], TypeImpl) is used

       

      This can lead to types incorrectly being added as not used into the parentTypesWithNoInstances IntVector which is used to add those types (duplicating the spec for a used type).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kphaison Hai-Son Nguyen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: