You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by "Hai-Son Nguyen (JIRA)" <de...@uima.apache.org> on 2019/08/09 17:33:00 UTC
[jira] [Closed] (UIMA-6112) JSON serializer produces repeated
duplicate types
[ https://issues.apache.org/jira/browse/UIMA-6112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hai-Son Nguyen closed UIMA-6112.
--------------------------------
Resolution: Duplicate
Already fixed in latest version
> 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.7.0SDK, 2.8.0SDK, 2.8.1SDK, 2.9.0SDK
> Reporter: Hai-Son Nguyen
> Priority: Critical
>
> 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)