-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle MalformedParameterizedTypeException in AnnotatedConstructor.getGenericParameterTypes(idx) #418
Comments
I think I'll need a unit test to show an example case; I have not seen this problem before. It should be possible to handle all type declarations; and whether type is abstract or not should not be problematic for type resolution. It may be problem for later processing (depending on whether polymorphic type info is available), but should not fail at resolution phase. Thank you for reporting the problem! |
I can't seem to be able to produce a free-standing unit test. When I create a free-standing class, I don't get the exception anymore. But this is the exception trace I am getting: The constructor signature that seems to cause this error looks like this:
Class This is what that class looks like:
|
After further digging I think I can see what is causing this issue and why I was not able to reproduce it in a clean, stand-alone test. :( |
Ah. And yes, since stack trace comes from within JDK, it's bit hard for Jackson to do much. Although if that would make a difference, it'd be possible to catch this exception and change message, to suggest likely problem. Would this make sense? |
Do you think it would be acceptable to just catch that exception at the source and ignore those constructors/types and fall back to use object creation by default constructor + fields, or fall back to the explicitly configured serializers for those types? I have tried to provide my own Module with the pre-configured Serializer for the type, but this exception comes up at the very beginning before any of the custom stuff comes into play. |
As I said, I don't like hiding real problems under carpet; this tends to leave to mysterious failures, and users are puzzled by what seems like a bug. I don't see this as a good solution. But you can disable creator introspection, or even all annotation introspection, which would avoid the problem. It would also make it impossible to use said annotations as downside. |
Currently the MalformedParameterizedTypeException is not being handled when trying to resolve the "creators" in POJOPropertiesCollector. This exception can be thrown by the JDK "Constructor" class when asking for "getGenericParameterTypes". This is typically happens if the JVM/JDK implementation does not think that the declared type can be instantiated (like having a List type [which is an interface] be declared as a constructor argument).
It seems that Jackson can handle List and Map types via other mechanisms, so maybe just ignoring those constructors that throw this exception is the best coarse of action and create the object using other (creatable) constructors or via direct field member setting.
The text was updated successfully, but these errors were encountered: