Affects: Spring-Messaging 6.0.3
I am currently implementing an application, that uses Protobuf over RSocket for communication. In Protobuf, I can define a message sent to my application like this:
message ProductsRequest {
optional string id = 1;
}
My MessageHandler is then defined like this:
@MessageMapping("products")
public Mono<ProductsResponse> handle(ProductsRequest request) {
// implementaion
}
The request may contain an id, but it may be omitted. In case the id is omitted, the message is encoded as an empty buffer (as per Protobuf spec).
However, in the class org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver
, empty buffers are never passed to the decoder, and instead immediately filtered out. (via .filter(this::nonEmptyDataBuffer)
, which then results in an error because the MessageHandler's argument cannot be resolved.
I understand that this behavior is reasonable for a lot of decoders, however in the case of Protobuf is a nuisance.
I think the best way to implement this is to add a property to the decoder ("can decode empty") and then filter or not, based on this property. I would gladly spend some time on this and come up with a pull request, but I wanted to have some guidance first, to not sent a crappy pull request.
So, roughly, how should this be implemented?
Comment From: simonbasle
Superseded by #29903
Comment From: simonbasle
(let's continue the conversation in the PR)