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

GuavaImmutableCollectionDeserializer cannot deserialize an empty Optional from null #53

Closed
jonfreedman opened this issue Jul 29, 2019 · 5 comments
Labels
Milestone

Comments

@jonfreedman
Copy link

The following test should pass

public void testImmutableListOfOptionals() throws IOException {
	ImmutableList<OptionalInt> list = MAPPER.readValue("[1,null,3]", new TypeReference<ImmutableList<OptionalInt>>() { });
	assertEquals(3, list.size());
	assertEquals(OptionalInt.of(1), list.get(0));
	assertEquals(OptionalInt.empty(), list.get(1));
	assertEquals(OptionalInt.of(3), list.get(2));
}

See #27

@cowtowncoder
Copy link
Member

I assume this is verified against 2.9.9?

@jonfreedman
Copy link
Author

jonfreedman commented Jul 30, 2019

I've verified against 2.9.6 but I checked your source, you need to change this line: https://github.com/FasterXML/jackson-datatypes-collections/blob/master/guava/src/main/java/com/fasterxml/jackson/datatype/guava/deser/GuavaImmutableCollectionDeserializer.java#L40

value = null;
becomes
value = valueDes.getNullValue(ctxt);

Same fix as 0fc5e8b#diff-3e1e6a8832674f14bb424827a0180c66L157

We have a copy of this specific class in our codebase so I had forgotten that you asked me to open a new issue until I went back through my github notifications.

@cowtowncoder
Copy link
Member

Got it, thanks!

@cowtowncoder cowtowncoder changed the title GuavaImmutableCollectionDeserializer cannot deserialize and empty Optional from null GuavaImmutableCollectionDeserializer cannot deserialize and empty Optional from null Aug 8, 2019
@cowtowncoder cowtowncoder changed the title GuavaImmutableCollectionDeserializer cannot deserialize and empty Optional from null GuavaImmutableCollectionDeserializer cannot deserialize an empty Optional from null Aug 8, 2019
@cowtowncoder cowtowncoder added this to the 2.10.0.pr2 milestone Aug 9, 2019
@cowtowncoder
Copy link
Member

I think this is now fixed, although for testing need to use AtomicReference for validation as I can not add dependency to JDK8 module to use Java 8 Optional types.

cowtowncoder added a commit that referenced this issue Aug 9, 2019
@jonfreedman
Copy link
Author

Thanks, I'll verify when you cut the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants