Skip to content

Commit 12ebddc

Browse files
committed
Fix #3522: support serialization of ByteArrayOutputStream instances
1 parent 0e2ab57 commit 12ebddc

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

release-notes/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Versions: 3.x (for earlier see VERSION-2.x)
6262
#3046: Rename `JsonSerializable` as `JacksonSerializable`
6363
#3047: Rename `Bean[De]SerializerModifier` as `Value[De]SerializerModifier`
6464
#3070: Change default for `SerializationFeature.FAIL_ON_EMPTY_BEANS` to `false`
65+
#3522: Support serializing `ByteArrayOutputStream` as "simple" Binary value
6566
#3536: Create new exception type `JsonNodeException` for use by `JsonNode`-related problems
6667
#3542: Rename "com.fasterxml.jackson" -> "tools.jackson"
6768
#3561: Add `DeserializationContext` as an argument for `SettableBeanProperty.set(...)`

src/test/java/tools/jackson/databind/ser/jdk/JDKTypeSerializationTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,15 @@ public void testThreadSerialization() throws Exception
258258
assertNotNull(cl);
259259
assertEquals(0, cl.size());
260260
}
261+
262+
// [databind#3522]: ByteArrayOutputStream
263+
@Test
264+
public void testByteArrayOutputStreamSerialization() throws Exception
265+
{
266+
byte[] bytes = new byte[] { 1, 11, 111 };
267+
final String exp = MAPPER.writeValueAsString(bytes);
268+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
269+
baos.write(bytes);
270+
assertEquals(exp, MAPPER.writeValueAsString(baos));
271+
}
261272
}

src/test/java/tools/jackson/databind/ser/jdk/JavaUtilDateSerializationTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,4 @@ private void serialize(ObjectWriter w, Object date, List<String> expected) throw
433433
String result = w.writeValueAsString(date);
434434
assertTrue(expected.contains(result), "unexpected result: " + result);
435435
}
436-
437-
private String zoneOffset(String raw) {
438-
// Add colon or not -- difference between 2.10 and earlier, 2.11 and later
439-
return raw.substring(0, 2) + ":" + raw.substring(2); // 2.11 and later
440-
// return raw; // 2.10 and earlier
441-
}
442436
}

0 commit comments

Comments
 (0)