micronaut-projects / micronaut-aws

Projects specific to integrating Micronaut and Amazon Web Services (AWS)
Apache License 2.0
82 stars 81 forks source link

Problem JSON Infinite Recursion on Serialization #2059

Closed driverpt closed 4 months ago

driverpt commented 4 months ago

Expected Behavior

To return proper Problem JSON

Actual Behaviour

Goes into infinite loop

Caused by: io.micronaut.http.codec.CodecException: Error encoding object [https://zalando.github.io/problem/constraint-violation{400, Constraint Violation}] to JSON: Document nesting depth (1001) exceeds the maximum allowed (1000, from `StreamWriteConstraints.getMaxNestingDepth()`)
    at io.micronaut.json.codec.MapperMediaTypeCodec.encode(MapperMediaTypeCodec.java:233)
    at io.micronaut.servlet.http.ServletHttpHandler.encodeResponse(ServletHttpHandler.java:464)
    ... 191 common frames omitted
Caused by: com.fasterxml.jackson.core.exc.StreamConstraintsException: Document nesting depth (1001) exceeds the maximum allowed (1000, from `StreamWriteConstraints.getMaxNestingDepth()`)
    at com.fasterxml.jackson.core.StreamWriteConstraints._constructException(StreamWriteConstraints.java:177)
    at com.fasterxml.jackson.core.StreamWriteConstraints.validateNestingDepth(StreamWriteConstraints.java:162)
    at com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeStartObject(UTF8JsonGenerator.java:380)
    at io.micronaut.serde.jackson.JacksonEncoder.encodeObject(JacksonEncoder.java:105)
    at io.micronaut.serde.support.serializers.CustomizedObjectSerializer.serialize(CustomizedObjectSerializer.java:57)
    at io.micronaut.serde.support.serializers.CustomizedObjectSerializer.serializeIntoInternal(CustomizedObjectSerializer.java:157)
    at io.micronaut.serde.support.serializers.CustomizedObjectSerializer.serialize(CustomizedObjectSerializer.java:58)
    at io.micronaut.serde.support.serializers.CustomizedObjectSerializer.serializeIntoInternal(CustomizedObjectSerializer.java:157)
    at io.micronaut.serde.support.serializers.CustomizedObjectSerializer.serialize(CustomizedObjectSerializer.java:58)
    at io.micronaut.serde.support.serializers.CustomizedObjectSerializer.serializeIntoInternal(CustomizedObjectSerializer.java:157)
    at io.micronaut.serde.support.serializers.CustomizedObjectSerializer.serialize(CustomizedObjectSerializer.java:58)

Steps To Reproduce

Checkout the Example application and run the tests

Environment Information

Example Application

https://github.com/driverpt/micronaut-aws-problem-json-issue

Version

4.3.2

aprietop commented 4 months ago

It seems to be related to issue https://github.com/micronaut-projects/micronaut-aws/issues/2056