Skip to content

Commit a1d0251

Browse files
committed
Fix #1411
1 parent 4e94c0e commit a1d0251

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

release-notes/CREDITS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Joern Huxhorn: (huxi@github)
1818
(2.0.0)
1919
* Reported #479: NPE on trying to deserialize a `String[]` that contains null
2020
(2.4.1)
21+
* Reported #1411: MapSerializer._orderEntries should check for null keys
22+
(2.7.9)
2123

2224
James Roper:
2325
* Requested [JACKSON-732]: Allow 'AnnotationIntrospector.findContentDeserializer()'

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Project: jackson-databind
88

99
#1392: Custom UnmodifiableSetMixin Fails in Jackson 2.7+ but works in Jackson 2.6
1010
(reported by Rob W)
11+
#1411: MapSerializer._orderEntries should check for null keys
12+
(reported by Jörn H)
1113

1214
2.7.8 (26-Sep-2016)
1315

src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,16 @@ protected Map<?,?> _orderEntries(Map<?,?> input)
933933
if (input instanceof SortedMap<?,?>) {
934934
return input;
935935
}
936+
// [databind#1411]: TreeMap does not like null key...
937+
if (input.containsKey(null)) {
938+
TreeMap<Object,Object> result = new TreeMap<Object,Object>();
939+
for (Map.Entry<?,?> entry : input.entrySet()) {
940+
Object key = entry.getKey();
941+
if (key != null) {
942+
result.put(key, entry.getValue());
943+
}
944+
}
945+
}
936946
return new TreeMap<Object,Object>(input);
937947
}
938948
}
939-

0 commit comments

Comments
 (0)