Skip to content

Commit dc02cea

Browse files
committed
Add a passing test to try to repro #1513
1 parent af2129c commit dc02cea

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,8 @@ protected Map<?,?> _orderEntries(Map<?,?> input, JsonGenerator gen,
950950
if (input instanceof SortedMap<?,?>) {
951951
return input;
952952
}
953-
// [databind#1411]: TreeMap does not like null key...
953+
// [databind#1411]: TreeMap does not like null key... (although note that
954+
// check above should prevent this code from being called in that case)
954955
if (input.containsKey(null)) {
955956
TreeMap<Object,Object> result = new TreeMap<Object,Object>();
956957
for (Map.Entry<?,?> entry : input.entrySet()) {

src/test/java/com/fasterxml/jackson/databind/ser/TestMapSerialization.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.*;
44
import java.util.*;
55
import java.util.concurrent.ConcurrentHashMap;
6+
import java.util.concurrent.ConcurrentSkipListMap;
67

78
import com.fasterxml.jackson.annotation.*;
89
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
@@ -284,4 +285,16 @@ public void testNullJsonInTypedMap691() throws Exception {
284285
String json = mapper.writeValueAsString(map);
285286
assertEquals("{\"@class\":\"java.util.HashMap\",\"NULL\":null}", json);
286287
}
288+
289+
// [databind#1513]
290+
public void testConcurrentSkipListMap() throws Exception
291+
{
292+
Map<String,String> input = new ConcurrentSkipListMap<String,String>();
293+
input.put("a", "b");
294+
input.put("x", "y");
295+
String json = MAPPER
296+
.writer().with(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)
297+
.writeValueAsString(input);
298+
assertEquals(aposToQuotes("{'a':'b','x':'y'}"), json);
299+
}
287300
}

0 commit comments

Comments
 (0)