-
Notifications
You must be signed in to change notification settings - Fork 628
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
regression possibly due to AMQP-807 #1093
Comments
garyrussell
added a commit
to garyrussell/spring-amqp
that referenced
this issue
Sep 16, 2019
Fixes spring-projects#1093 AMQP-807 added support for generic return types; however this broke abstract return types since the `__TypeId__` header was set to the abstract type. If the return type is not a container type and represents an abstract class or interterface use the concrete return type to construct the `JavaType`.
garyrussell
added a commit
to garyrussell/spring-amqp
that referenced
this issue
Sep 16, 2019
Fixes spring-projects#1093 AMQP-807 added support for generic return types; however this broke abstract return types since the `__TypeId__` header was set to the abstract type. If the return type is not a container type and represents an abstract class or interterface use the concrete return type to construct the `JavaType`. **cherry-pick to 2.1.x**
artembilan
pushed a commit
that referenced
this issue
Sep 16, 2019
Fixes #1093 AMQP-807 added support for generic return types; however this broke abstract return types since the `__TypeId__` header was set to the abstract type. If the return type is not a container type and represents an abstract class or interterface use the concrete return type to construct the `JavaType`. **cherry-pick to 2.1.x**
artembilan
pushed a commit
that referenced
this issue
Sep 16, 2019
Fixes #1093 AMQP-807 added support for generic return types; however this broke abstract return types since the `__TypeId__` header was set to the abstract type. If the return type is not a container type and represents an abstract class or interterface use the concrete return type to construct the `JavaType`. **cherry-pick to 2.1.x** # Conflicts: # spring-amqp/src/main/java/org/springframework/amqp/support/converter/AbstractJackson2MessageConverter.java
garyrussell
added a commit
to garyrussell/spring-amqp
that referenced
this issue
Sep 16, 2019
- redundant since interfaces are always abstract
artembilan
pushed a commit
that referenced
this issue
Sep 16, 2019
- redundant since interfaces are always abstract
artembilan
pushed a commit
that referenced
this issue
Sep 16, 2019
- redundant since interfaces are always abstract
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As asked by @garyrussell, here is the Github issue related to stack overflow https://stackoverflow.com/questions/57927606/spring-amqp-jackson2jsonmessageconverter-setup-typeid-with-interface-instead
The problem
We have upgraded our Spring-boot version from 2.0.5 to 2.1.8.
As a result, Spring AMQP upgraded from 2.0.6 to 2.1.8 also.
Since then
Jackson2JsonMessageConverter
is unable to parse answer messages coming from methods annotated with @RabbitListener because they return an interface (actually declared as a generic in the code). And this interface is used to set the message_TypeId_
property .with version 2.0 it used to set TypeId with the actual concrete class.
I did some digging and here is my understanding of the problem (code will follow)
When the method annotated with @RabbitListener returns, the
MessagingMessageListenerAdapter#onMessage
is invoked and encapsulates the result in aInvocationResult
Object, which contains agenericType
property.This
genericType
is set up from the return type of the method annotated with @RabbitListener.Then, it is used by the
Jackson2JsonMessageConverter#createMessage
method to setup_TypeId_
property.On the other side, the
Jackson2JsonMessageConverter#fromMessage
can then parse the Json using this propery to find out the actual Type.The problem is that, since the introduction of
InvocationResult
andgenericType
, our method annotated with @RabbitListener is declared as returning an interface and so the_TypeId_
property is set up with the interface instead of the actual concrete class. Here is the bit of code fromJackson2JsonMessageConverter#fromMessage
(actualy fromAbstractJackson2MessageConverter
)which has changed (among other):Since genericType is not null and contains the interfaceType... you can see our trouble.
Prior to version 2.1, we add no problem since the Jackson2JsonMessageConverter#createMessage() was always directly using
objectToConvert.getClass()
:The code
Here is our code:
Of course, the content of
receiveMessage
method is simplified, the point is that the actual implementation can return differents concretes types depending of the input concrete typeThe text was updated successfully, but these errors were encountered: