File tree Expand file tree Collapse file tree
aws-xray-recorder-sdk-core/src
main/java/com/amazonaws/xray/entities
test/java/com/amazonaws/xray/entities Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828import com .fasterxml .jackson .databind .ObjectMapper ;
2929import com .fasterxml .jackson .databind .PropertyNamingStrategy ;
3030import com .fasterxml .jackson .databind .SerializationConfig ;
31+ import com .fasterxml .jackson .databind .SerializationFeature ;
3132import com .fasterxml .jackson .databind .annotation .JsonSerialize ;
3233import com .fasterxml .jackson .databind .module .SimpleModule ;
3334import com .fasterxml .jackson .databind .node .NullNode ;
@@ -58,6 +59,7 @@ public abstract class EntityImpl implements Entity {
5859 @ Deprecated
5960 protected static final ObjectMapper mapper = new ObjectMapper ()
6061 .findAndRegisterModules ()
62+ .configure (SerializationFeature .FAIL_ON_EMPTY_BEANS , false )
6163 .setPropertyNamingStrategy (PropertyNamingStrategy .CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES )
6264 .setSerializationInclusion (JsonInclude .Include .NON_EMPTY );
6365
Original file line number Diff line number Diff line change @@ -67,4 +67,16 @@ void testDateSerialization() {
6767 String expected = "{\" default\" :{\" date\" :1616559298000}}" ;
6868 assertThat (serializedSeg ).contains (expected );
6969 }
70+
71+ @ Test
72+ void testUnknownClassSerialization () {
73+ Segment seg = new SegmentImpl (AWSXRay .getGlobalRecorder (), "test" );
74+ seg .putAws ("coolService" , new EmptyBean ());
75+ seg .end ();
76+ seg .serialize (); // Verify we don't crash here
77+ }
78+
79+ static class EmptyBean {
80+ String otherField = "cerealization" ;
81+ }
7082}
You can’t perform that action at this time.
0 commit comments