Description
JsonMappingException is a checked exception used to signal fatal problems with mapping of content.
UnresolvedForwardReference, which extends JsonMappingException is thrown and caught internally for completely VALID json to resolve forward references.
Throwable.fillInStackTrace() is an expensive operation, it's the main cost of throwing most Exceptions, and it's called for all UnresolvedForwardReference thrown and caught internally. The stackTrace is irrelevant for these internal exceptions, it is wasted computation.
The json documents we process are full of object references, so I took the liberty of locally redefining UnresolvedForwardReference to extend RuntimeException, and using the RuntimeException constructor to set writableStackTrace to false, bypassing the Throwable.fillInStackTrace() call.
I noticed speed improvements of 50%, deserialization takes half the time when Throwable.fillInStackTrace() is turned off for our typical json payloads.
DeserializationContext does have a method checkUnresolvedObjectId(), which throws the genuine fatal unresolved forward references.
All I'm asking is that UnresolvedForwardReference thrown and caught internally are created with writableStackTrace = false, whether that's achieved by supplying new parent constructors to pass the flag up the hierarchy, or creating a new exception type that's only used internally to report a forward reference to be resolved later, It need not be a breaking change, only an internal performance improvement.