Skip to content

Prevent deserialization of "" as null for Duration, Instant, LocalTime, OffsetTime, Period, ZoneDateTime, ZoneId, ZoneOffset and YearMonth in "strict" (non-lenient) #144

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

Merged

Conversation

kupci
Copy link
Member

@kupci kupci commented Oct 17, 2019

For the java.time classes Duration, Instant, LocalTime, OffsetDateTime, OffsetTime, Period, ZoneDateTime, ZoneId, ZoneOffset and YearMonth, this fix prevents an empty string from being mapped to null where the "strict" (non-lenient) configuration is set.

See issue #138

@kupci
Copy link
Member Author

kupci commented Oct 17, 2019

This is ready for review, though still need to add fix to JSR310StringParsableDeserializer, and a few more tests for the types that pass through to Java's date/time API, and thus are already strict.

@kupci kupci changed the title Prevent deserialization of "" as null for Duration, Instant, LocalTime, OffsetTime, and YearMonth in "strict" (non-lenient) Prevent deserialization of "" as null for Duration, Instant, LocalTime, OffsetTime, Period, ZoneDateTime, ZoneId, ZoneOffset and YearMonth in "strict" (non-lenient) Oct 17, 2019
@kupci kupci marked this pull request as ready for review October 17, 2019 06:09
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.*;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IntelliJ is helpfully removing all the imports and starring them, I'll need to find that setting and fix this...

import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.*;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix imports

import com.fasterxml.jackson.datatype.jsr310.MockObjectConfiguration;
import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase;

import org.junit.Test;

import static org.junit.Assert.*;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style...

@cowtowncoder
Copy link
Member

LGTM (quick glance, but based on previous work, scope, I don't see high risk). Makes sense for 2.11 in particular, will merge.

@cowtowncoder cowtowncoder merged commit f063193 into FasterXML:2.11 Oct 18, 2019
@kupci kupci deleted the empty-string-to-null-if-lenient-2.11 branch October 19, 2019 19:14
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

Successfully merging this pull request may close these issues.

None yet

2 participants