NPE in getItemType if type hierarchy is null for merged maps.
I have a query that is merging two maps:
Here, the first map has attribute-based keys, while the second has xs:string based keys.
That query succeeds. However, when I call Item.getItemType with a null type hierarchy I get the following exception in Saxon 188.8.131.52:
Caused by: java.lang.NullPointerException at net.sf.saxon.type.Type.getCommonSuperType(Type.java:374) at net.sf.saxon.ma.map.HashTrieMap.getItemType(HashTrieMap.java:280) at net.sf.saxon.ma.map.HashTrieMap.getItemType(HashTrieMap.java:32) at net.sf.saxon.type.Type.getItemType(Type.java:213)
Looking at the source code for Type.getCommonSuperType at line 374, it is calling
int r = th.relationship(t1, t2);
without checking that th is null (which is allowed per the documentation on Type.getItemType).
This issue is also present in Saxon 10. The only difference is that the return type has changed to Affinity.
#5 Updated by Michael Kay over 1 year ago
- Category set to Internals
- Status changed from New to Resolved
- Assignee set to Michael Kay
- Priority changed from Low to Normal
- Fix Committed on Branch 10, 9.9 added
Patch committed. The method
Type.getItemType(), when applied to a map or array, with no
TypeHierarchy supplied, will now return the generic type
Note that if the item is an external object, the typeHierarchy parameter must be non-null, and we will note this in the Javadoc.
Please register to edit this issue