From 425513b76f5c661332c4b2eb6b1aa38e182d1a5d Mon Sep 17 00:00:00 2001 From: Cowtowncoder Date: Tue, 13 Jan 2015 09:21:25 -0800 Subject: [PATCH] Added release notes wrt #51 --- release-notes/CREDITS | 4 ++ release-notes/VERSION | 5 +++ .../datatype/joda/JodaSerializationTest.java | 41 ++++++++++--------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/release-notes/CREDITS b/release-notes/CREDITS index eae5873c..cdf1580b 100644 --- a/release-notes/CREDITS +++ b/release-notes/CREDITS @@ -24,3 +24,7 @@ Brad Kennedy (bkenned4@github) * Contributed #45: Can't use LocalTime, LocalDate & LocalDateTime as Key type for a Map (2.4.3) +Charlie La Mother (clamothe@github) + + * Contributed #51: Calling `JodaDateSerializerBase.isEmpty()` results in a `StackOverflowError`. + (2.5.1) diff --git a/release-notes/VERSION b/release-notes/VERSION index 4d20d79f..91fa5a9f 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -4,6 +4,11 @@ Project: jackson-datatype-joda === Releases === ------------------------------------------------------------------------ +2.5.1 (not yet released) + +#51: Calling `JodaDateSerializerBase.isEmpty()` results in a `StackOverflowError`. + (reported, fix contributed by Charlie L-M) + 2.5.0 (01-Jan-2015) No changes since 2.4 diff --git a/src/test/java/com/fasterxml/jackson/datatype/joda/JodaSerializationTest.java b/src/test/java/com/fasterxml/jackson/datatype/joda/JodaSerializationTest.java index 71f909ea..ad0d20ce 100644 --- a/src/test/java/com/fasterxml/jackson/datatype/joda/JodaSerializationTest.java +++ b/src/test/java/com/fasterxml/jackson/datatype/joda/JodaSerializationTest.java @@ -1,8 +1,6 @@ package com.fasterxml.jackson.datatype.joda; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; import com.fasterxml.jackson.annotation.JsonInclude; import org.joda.time.*; @@ -18,19 +16,32 @@ public class JodaSerializationTest extends JodaTestBase private static interface ObjectConfiguration { } + static class Container { + T contents; + + public Container(T contents) { + this.contents = contents; + } + + public T getContents() { + return contents; + } + } + private final ObjectMapper MAPPER = jodaMapper(); { MAPPER.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); MAPPER.enable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS); } + private final ObjectWriter WRITER = MAPPER.writer(); - + /* /********************************************************** /* Tests for DateMidnight type /********************************************************** */ - + public void testDateMidnightSer() throws IOException { DateMidnight date = new DateMidnight(2001, 5, 25); @@ -70,15 +81,17 @@ public void testLocalDateSer() throws IOException // but we can force it to be a String as well (note: here we assume this is // dynamically changeable) - ObjectMapper mapper = jodaMapper(); - mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - assertEquals(quote("2001-05-25"), mapper.writeValueAsString(date)); + assertEquals(quote("2001-05-25"), + WRITER.without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).writeValueAsString(date)); // We can also configure beans to not include empty values. In this case, // JodaDateSerializerBase#isEmpty is called to check if the value is empty. - mapper = jodaMapper(); + ObjectMapper mapper = jodaMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); assertEquals("{\"contents\":[2001,5,25]}", mapper.writeValueAsString(new Container(date))); + + // also verify pruning by NON_EMPTY + assertEquals("{}", mapper.writeValueAsString(new Container(null))); } public void testLocalDateSerWithTypeInfo() throws IOException @@ -238,16 +251,4 @@ public void testYearMonthSer() throws Exception assertEquals(quote("2013-08"), json); } - private static class Container { - T contents; - - public Container(T contents) { - this.contents = contents; - } - - public T getContents() { - return contents; - } - } - }