Skip to content

Commit

Permalink
Added release notes wrt #51
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 13, 2015
1 parent 2f6dd16 commit 425513b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
4 changes: 4 additions & 0 deletions release-notes/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 5 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*;
Expand All @@ -18,19 +16,32 @@ public class JodaSerializationTest extends JodaTestBase
private static interface ObjectConfiguration {
}

static class Container<T> {
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);
Expand Down Expand Up @@ -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<LocalDate>(date)));

// also verify pruning by NON_EMPTY
assertEquals("{}", mapper.writeValueAsString(new Container<LocalDate>(null)));
}

public void testLocalDateSerWithTypeInfo() throws IOException
Expand Down Expand Up @@ -238,16 +251,4 @@ public void testYearMonthSer() throws Exception
assertEquals(quote("2013-08"), json);
}

private static class Container<T> {
T contents;

public Container(T contents) {
this.contents = contents;
}

public T getContents() {
return contents;
}
}

}

0 comments on commit 425513b

Please sign in to comment.