Closed
Description
Greg Turnquist opened DATAREDIS-492 and commented
MappingRedisConverter.writeInternal() does a check against properties. If they are "collection like" then they get cast as Collection<?>. However, isCollectionLike() detects iterables, arrays, and collections, hence this is a faulty assumption for casting.
...
if (persistentProperty.isMap()) {
writeMap(keyspace, propertyStringPath, persistentProperty.getMapValueType(),
(Map<?, ?>) accessor.getProperty(persistentProperty), sink);
} else if (persistentProperty.isCollectionLike()) {
writeCollection(keyspace, propertyStringPath, (Collection<?>) accessor.getProperty(persistentProperty),
persistentProperty.getTypeInformation().getComponentType(), sink);
} else if (persistentProperty.isEntity()) {
writeInternal(keyspace, propertyStringPath, accessor.getProperty(persistentProperty),
persistentProperty.getTypeInformation().getActualType(), sink);
} else {
Object propertyValue = accessor.getProperty(persistentProperty);
writeToBucket(propertyStringPath, propertyValue, sink, persistentProperty.getType());
}
...
TypeDiscoverer.isCollectionLike...
public boolean isCollectionLike() {
Class<?> rawType = getType();
if (rawType.isArray() || Iterable.class.equals(rawType)) {
return true;
}
return Collection.class.isAssignableFrom(rawType);
}
Issue Links:
- DATAREDIS-495 Arrays are incorrectly considered Collections
("is duplicated by")
Referenced from: pull request #189
Backported to: 1.7.2 (Hopper SR2)