Skip to content

Commit

Permalink
Minor tweak to FasterXML#4303 tests, add release note
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder authored and Philzen committed Apr 26, 2024
1 parent 7a6ac8e commit cb8d130
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
4 changes: 4 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Not yet released
does not work
(reported by @jonasho)
(fix contributed by Joo-Hyuk K)
#4303: `ObjectReader` is not serializable if it's configured for polymorphism
(reported by @asardaes)
(fix contributed by Joo-Hyuk K)


2.15.3 (12-Oct-2023)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.fasterxml.jackson.databind;

import java.io.*;
import java.util.*;

import com.fasterxml.jackson.annotation.*;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.type.TypeFactory;

Expand Down Expand Up @@ -101,7 +99,7 @@ class FooNameImpl extends FooName { }
*/
private final ObjectMapper MAPPER = newJsonMapper();

public void testConfigs() throws IOException
public void testConfigs() throws Exception
{
byte[] base = jdkSerialize(MAPPER.getDeserializationConfig().getBaseSettings());
assertNotNull(jdkDeserialize(base));
Expand All @@ -122,7 +120,7 @@ public void testConfigs() throws IOException
}

// for [databind#899]
public void testEnumHandlers() throws IOException
public void testEnumHandlers() throws Exception
{
ObjectMapper mapper = newJsonMapper();
// ensure we have serializers and/or deserializers, first
Expand Down Expand Up @@ -155,7 +153,7 @@ public void testEnumHandlers() throws IOException
assertNotNull(result2);
}

public void testObjectWriter() throws IOException
public void testObjectWriter() throws Exception
{
ObjectWriter origWriter = MAPPER.writer();
final String EXP_JSON = "{\"x\":2,\"y\":3}";
Expand All @@ -169,7 +167,7 @@ public void testObjectWriter() throws IOException
assertEquals(EXP_JSON, writer2.writeValueAsString(p));
}

public void testObjectReader() throws IOException
public void testObjectReader() throws Exception
{
ObjectReader origReader = MAPPER.readerFor(MyPojo.class);
String JSON = "{\"x\":1,\"y\":2}";
Expand All @@ -189,7 +187,7 @@ public void testObjectReader() throws IOException
assertEquals(Integer.valueOf(2), any2.properties().get("y"));
}

public void testObjectMapper() throws IOException
public void testObjectMapper() throws Exception
{
final String EXP_JSON = "{\"x\":2,\"y\":3}";
final MyPojo p = new MyPojo(2, 3);
Expand Down Expand Up @@ -236,13 +234,14 @@ public void testObjectReaderSerializationWithPolymorphism()
};

for (Class<?> clazz : classes) {
// Should be enough to ask for reader for polymorphic type
// (no need to actually serialize/deserialize)
ObjectReader reader = newJsonMapper()
.readerFor(clazz);

ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(reader); // This line should throw NotSerializableException
oos.close();
byte[] bytes = jdkSerialize(reader);
ObjectReader result = jdkDeserialize(bytes);
assertNotNull(result);
}
}
}

0 comments on commit cb8d130

Please sign in to comment.