Skip to content

Commit 139f691

Browse files
committed
Merge branch '2.10' into 2.11
2 parents b7593a5 + dd79fab commit 139f691

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.fasterxml.jackson.dataformat.cbor.parse;
2+
3+
import java.util.*;
4+
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.fasterxml.jackson.dataformat.cbor.CBORTestBase;
7+
8+
// Tests for [dataformat-binary#188], lacking coercions for Binary->String wrt containers
9+
public class BinaryToStringCoercionTest extends CBORTestBase
10+
{
11+
static class BinaryListWrapper {
12+
public List<byte[]> data = Collections.singletonList(
13+
new byte[] { 1, 2, 3, 4});
14+
}
15+
16+
static class StringListWrapper {
17+
public List<String> data;
18+
}
19+
20+
static class BinarySetWrapper {
21+
public Set<byte[]> data = Collections.singleton(new byte[] { 1, 2, 3, 4});
22+
}
23+
24+
static class StringSetWrapper {
25+
public Set<String> data;
26+
}
27+
28+
static class BinaryArrayWrapper {
29+
public byte[][] data = new byte[][] { new byte[] { 1, 2, 3, 4} };
30+
}
31+
32+
static class StringArrayWrapper {
33+
public String[] data;
34+
}
35+
36+
static class BinaryMapWrapper {
37+
public Map<String, byte[]> data = Collections.singletonMap("key",
38+
new byte[] { 1, 2, 3, 4});
39+
}
40+
41+
static class StringMapWrapper {
42+
public Map<String, String> data;
43+
}
44+
45+
private final ObjectMapper CBOR_MAPPER = cborMapper();
46+
47+
public void testWithList() throws Exception
48+
{
49+
byte[] doc = CBOR_MAPPER.writeValueAsBytes(new BinaryListWrapper());
50+
StringListWrapper result = CBOR_MAPPER.readValue(doc, StringListWrapper.class);
51+
assertEquals(1, result.data.size());
52+
assertEquals(String.class, result.data.get(0).getClass());
53+
}
54+
55+
public void testWithSet() throws Exception
56+
{
57+
byte[] doc = CBOR_MAPPER.writeValueAsBytes(new BinarySetWrapper());
58+
StringSetWrapper result = CBOR_MAPPER.readValue(doc, StringSetWrapper.class);
59+
assertEquals(1, result.data.size());
60+
assertEquals(String.class, result.data.iterator().next().getClass());
61+
}
62+
63+
public void testWithMap() throws Exception
64+
{
65+
byte[] doc = CBOR_MAPPER.writeValueAsBytes(new BinaryMapWrapper());
66+
StringMapWrapper result = CBOR_MAPPER.readValue(doc, StringMapWrapper.class);
67+
assertEquals(1, result.data.size());
68+
assertEquals(String.class, result.data.get("key").getClass());
69+
}
70+
71+
public void testWithArray() throws Exception
72+
{
73+
byte[] doc = CBOR_MAPPER.writeValueAsBytes(new BinaryArrayWrapper());
74+
StringArrayWrapper result = CBOR_MAPPER.readValue(doc, StringArrayWrapper.class);
75+
assertEquals(1, result.data.length);
76+
assertEquals(String.class, result.data[0].getClass());
77+
}
78+
}
79+

release-notes/CREDITS-2.x

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,8 @@ John (iziamos@github)
112112
Paul Adolph (padolph@github)
113113
* Reported #185: Internal parsing of tagged arrays can lead to stack overflow
114114
(2.10.1)
115+
116+
Yanming Zhou (quaff@github)
117+
* Reported #188: Unexpected `MismatchedInputException` for `byte[]` value bound to `String`
118+
in collection/array
119+
(2.10.1)

release-notes/VERSION-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Project: jackson-datatypes-binaryModules:
1616

1717
#185: Internal parsing of tagged arrays can lead to stack overflow
1818
(reported by Paul A)
19+
#188: Unexpected `MismatchedInputException` for `byte[]` value bound to `String`
20+
in collection/array (actual fix in `jackson-databind`)
21+
(reported by Yanming Z)
1922

2023
2.10.0 (26-Sep-2019)
2124

0 commit comments

Comments
 (0)