Skip to content

MappingRedisConverter does not support collection-like values in maps [DATAREDIS-722] #1297

Open
@spring-projects-issues

Description

@spring-projects-issues

Jonathan ROQUES opened DATAREDIS-722 and commented

In a model class (called MyClass) I have an attribute as :

private Map<String, Set<String>> attr = new HashMap<>();

When using :

new ObjectHashMapper().toHash(myClassInstance);

It throw a NullPointerException :

java.lang.NullPointerException
	at org.springframework.data.redis.core.convert.MappingRedisConverter.writeInternal(MappingRedisConverter.java:556)
	at org.springframework.data.redis.core.convert.MappingRedisConverter.writeMap(MappingRedisConverter.java:787)
	at org.springframework.data.redis.core.convert.MappingRedisConverter.access$700(MappingRedisConverter.java:114)
	at org.springframework.data.redis.core.convert.MappingRedisConverter$3.doWithPersistentProperty(MappingRedisConverter.java:572)
	at org.springframework.data.redis.core.convert.MappingRedisConverter$3.doWithPersistentProperty(MappingRedisConverter.java:558)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:330)
	at org.springframework.data.redis.core.convert.MappingRedisConverter.writeInternal(MappingRedisConverter.java:558)
	at org.springframework.data.redis.core.convert.MappingRedisConverter.writeMap(MappingRedisConverter.java:787)
	at org.springframework.data.redis.core.convert.MappingRedisConverter.access$700(MappingRedisConverter.java:114)
	at org.springframework.data.redis.core.convert.MappingRedisConverter$3.doWithPersistentProperty(MappingRedisConverter.java:572)
	at org.springframework.data.redis.core.convert.MappingRedisConverter$3.doWithPersistentProperty(MappingRedisConverter.java:558)
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:330)
	at org.springframework.data.redis.core.convert.MappingRedisConverter.writeInternal(MappingRedisConverter.java:558)
	at org.springframework.data.redis.core.convert.MappingRedisConverter.write(MappingRedisConverter.java:380)
	at org.springframework.data.redis.hash.ObjectHashMapper.toHash(ObjectHashMapper.java:107)

It seems that because the HashSet is backed by a Map with null values, MappingRedisConverter has some trouble to deal with Sets in Map


Affects: 1.8.8 (Ingalls SR8)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions