Hai-Son Nguyen created UIMA-6112: ------------------------------------ Summary: JSON serializer produces repeated duplicate types Key: UIMA-6112 URL: https://issues.apache.org/jira/browse/UIMA-6112 Project: UIMA Issue Type: Bug Components: UIMA Affects Versions: 2.9.0SDK Reporter: Hai-Son Nguyen
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). -- This message was sent by Atlassian JIRA (v7.6.14#76016)