Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapDeserializer fails on @JsonCreate #177

Closed
chisui opened this issue Jan 11, 2021 · 1 comment
Closed

MapDeserializer fails on @JsonCreate #177

chisui opened this issue Jan 11, 2021 · 1 comment

Comments

@chisui
Copy link

chisui commented Jan 11, 2021

The following Code fails:

static class SomeObject {
  @JsonCreator static SomeObject create(Map<String, String> someMap) {
    return new SomeObject();
  }
}

@Test
void shouldUseJsonCreator() throws Exception {
  new ObjectMapper()
      .registerModule(new VavrModule())
      .readValue("{}", SomeObject.class);
}
java.lang.NullPointerException
	at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:57)
	at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:10)
	at io.vavr.jackson.datatype.deserialize.MapDeserializer.deserialize(MapDeserializer.java:67)
	at io.vavr.jackson.datatype.deserialize.MapDeserializer.deserialize(MapDeserializer.java:35)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1315)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:331)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:164)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4524)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3466)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3434)

The issue seems to be that MapDeserializer doesn't ensure that the current token is a valid field name before invoking the KeyDeserializer.

@chisui chisui mentioned this issue Jan 11, 2021
ruslansennov added a commit that referenced this issue Jan 12, 2021
@chisui
Copy link
Author

chisui commented Jan 12, 2021

resolved by #178

@chisui chisui closed this as completed Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant