spring-projects / spring-projects/spring-data-redis

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

Open
#1,297 4 comments 0 reactions 1 assignee View on GitHub

@mp911de is already working on this.

Since Dec 30, 2020.

in: core type: enhancement
Dominant language
Java
Stars
1.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.