-
Notifications
You must be signed in to change notification settings - Fork 38.2k
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
ProtobufMessageConverter fails to parse JSON payload if byte array is used #27408
Comments
Yes although it looks a bit odd to me that the |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
Hi, I just ran into this exact same issue on a project. My use case is to read Protobuf messages from Kafka (has ByteArray native payload format) and Following the answer here https://stackoverflow.com/questions/70121156/how-to-use-org-springframework-messaging-converter-protobufmessageconverter have subclassed This works OK for binary protobuf encoding, when Looking at other MessageConverters, they seem to support multiple payload types, therefore I believe in ProtobufMessageConverter it is a bug.
|
Another related shortcoming: If |
I have the exact same problem here |
Affects: org.springframework:spring-messaging:5.3.6
We are using org.springframework:spring-messaging:5.3.6 with com.google.protobuf:protobuf-java:3.13.0 and com.google.protobuf:protobuf-java-util:3.13.0 to send and receive protobuf messages as application/json.
message.getPayload()
returns a byte array (GenericMessage [payload=byte[230], headers={...}]). CallingtoString
on a byte array produces a string similar to "[B@27fe3806".Attempt to parse resulting string as JSON produces the following error:
I assume that byte arrays need special handling so that we use String constructor instead of
toString()
call in order to get actual JSON content (i.e. something akin tonew String(message.getPayload(), StandardCharsets.UTF_8)
).The text was updated successfully, but these errors were encountered: