spring-projects / spring-projects/spring-data-rest

Enum Translation with Collections of Enums throws NullPointer [DATAREST-929]

Open
#1,292 3 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Mathias D opened DATAREST-929 and commented

Deserialization of Collections of enums with enum translation turned on fails with a NullPointerException

Caused by: java.lang.NullPointerException: null
	at org.springframework.data.rest.webmvc.json.EnumTranslator.resolveEnum(EnumTranslator.java:148) ~[spring-data-rest-webmvc-2.5.4.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.json.EnumTranslator.fromText(EnumTranslator.java:120) ~[spring-data-rest-webmvc-2.5.4.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.json.JacksonSerializers$EnumTranslatingDeserializer.deserialize(JacksonSerializers.java:184) ~[spring-data-rest-webmvc-2.5.4.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.json.JacksonSerializers$EnumTranslatingDeserializer.deserialize(JacksonSerializers.java:128) ~[spring-data-rest-webmvc-2.5.4.RELEASE.jar:na]
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:277) ~[jackson-databind-2.8.3.jar:2.8.3]

In this case, the type passed into EnumTranslator#fromText is e.g. java.util.Set where it should be the type contained in the collection. So EnumTranslatingDeserializer#deserialize could be enhanced with a special handling for arrays and collections


Affects: 2.5.4 (Hopper SR4)

Referenced from: pull request https://github.com/spring-projects/spring-data-rest/pull/234

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.