Skip to content

Improve error handling when resolving message payloads [SPR-14394] #18967

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

Closed
spring-projects-issues opened this issue Jun 23, 2016 · 3 comments
Closed
Assignees
Labels
in: messaging Issues in messaging modules (jms, messaging) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Thomas Hehl opened SPR-14394 and commented

The error handling provides insufficient information to resolve the error when no converter is found. What follows is lines 117-120 of PayloadArgumentResolver.java.

{{ if (payload == null) {
throw new MessageConversionException(message,
"No converter found to convert to " + targetClass + ", message=" + message);
}}}

This does not provide information about the payload class that it's trying to convert. Error handling should be:

{{ if (payload == null) {
throw new MessageConversionException(message,
"No converter found to convert to " + targetClass + ", from " + payload.getClass() + ", message=" + message);
}}}


Affects: 4.2.5, 4.2.6

Reference URL: https://github.com/spring-projects/spring-framework/blob/4.2.x/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/PayloadArgumentResolver.java

Referenced from: commits 07c9c55, f5282bc

Backported to: 4.2.7

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Good catch! I've generally revised that exception message, also mentioning the original payload class now.

@spring-projects-issues
Copy link
Collaborator Author

Thomas Hehl commented

Excellent! So this will be in the next snapshot build?

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed, the upcoming 4.3.1.BUILD-SNAPSHOT will have it. I'll backport it to 4.2.7 tomorrow.

@spring-projects-issues spring-projects-issues added in: messaging Issues in messaging modules (jms, messaging) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.3.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants