Merge pull request #5436 from tomj-vm/master

Fix: JsonJacksonCodec fails to serialize Throwable on Java17
pull/5457/head
Nikita Koksharov 1 year ago committed by GitHub
commit 6266e12581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -65,7 +65,7 @@ public class JsonJacksonCodec extends BaseCodec {
public static final JsonJacksonCodec INSTANCE = new JsonJacksonCodec();
@JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class, property="@id")
@JsonAutoDetect(fieldVisibility = Visibility.ANY,
@JsonAutoDetect(fieldVisibility = Visibility.NON_PRIVATE,
getterVisibility = Visibility.PUBLIC_ONLY,
setterVisibility = Visibility.NONE,
isGetterVisibility = Visibility.NONE)

@ -2,6 +2,7 @@ package org.redisson.codec;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -37,6 +38,17 @@ public class JsonJacksonCodecTest {
});
}
@Test
public void shouldSerializeAndDeserializeThrowable() throws JsonProcessingException {
//given
ObjectMapper objectMapper = JsonJacksonCodec.INSTANCE.getObjectMapper();
//when
String serialized = objectMapper.writeValueAsString(new RuntimeException("Example message"));
RuntimeException deserialized = objectMapper.readValue(serialized, RuntimeException.class);
//then
Assertions.assertEquals("Example message", deserialized.getMessage());
}
@Test
public void shouldNotOverrideProvidedObjectMapperProperties() {
ObjectMapper objectMapper = new ObjectMapper();

Loading…
Cancel
Save