DATAREDIS-1001 - Fix java.util.Date hash mapping when flattening out entries.
The AsArrayTypeDeserializer causes date values to be rendered as an array like [java.util.Date, 1561543964015] an therefore is 1. skipped when flattening and 2. if not skipped cannot be read back. We now register an error handler along with a custom deserializer aware of the used date format to write and read date values without having to store an array but just the date msec. Original pull request: #467.
This commit is contained in:
committed by
Mark Paluch
parent
b72bf41d02
commit
a2831bef84
@@ -97,5 +97,4 @@ public class Jackson2HashMapperTests {
|
||||
Person result = (Person) mapper.fromHash(template.<String, Object> opsForHash().entries("JON-SNOW"));
|
||||
Assert.assertThat(result, Is.is(jon));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import lombok.Data;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -161,6 +162,16 @@ public class Jackson2HashMapperUnitTests extends AbstractHashMapperTest {
|
||||
assertBackAndForwardMapping(outer);
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1001
|
||||
public void dateValueShouldBeTreatedCorrectly() {
|
||||
|
||||
WithDate source = new WithDate();
|
||||
source.string = "id-1";
|
||||
source.date = new Date(1561543964015L);
|
||||
|
||||
assertBackAndForwardMapping(source);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class WithList {
|
||||
List<String> strings;
|
||||
@@ -174,4 +185,11 @@ public class Jackson2HashMapperUnitTests extends AbstractHashMapperTest {
|
||||
Map<String, Object> objects;
|
||||
Map<String, Person> persons;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class WithDate {
|
||||
|
||||
private String string;
|
||||
private Date date;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user