Details
-
Improvement
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
-
None
-
1
Description
https://forums.couchbase.com/t/deserialize-issue-with-json-property/33041
Using the shaded annotations json/jackson annotations when unshaded are available is broken because the unshaded serializer will be used and the unshaded serializer only looks for unshaded annotations.
Suppose someone makes an application without the unshaded jackson jar - thus relying on the shaded jackson jar with the shaded annotations. Then, unbeknownst to the usage of the couchbase sdk in that app, the unshaded jackson jar is added to the classpath. The usage of the annotations will no longer work.
Proposed solution is to introduce a custom Jackson Annotation Introspector which
a) if the unshaded jackson jar is present and lookup for an unshaded annotation does not find an annotation, then look for the shaded version of that annotation, and if found, return an proxy for the shaded version which has the interface of the unshaded version (if it does not, then the casting to the unshaded version by the caller with fail); OR
b) if the unshaded jackson jar is present and there is a lookup for an unshaded annotation - throw an exception that wrong type of annotation is present.
I've attached a prototype with a test case. The prototype only works when the unshaded jar is present and only for JsonProperty, but you get the idea.