1
我有一个Spring Boot应用程序正在运行。请求/响应发送protobuf(Protobuf3)编码。处理空请求体(protobuf3编码)
我(简体)REST控制器:
@RestController
public class ServiceController {
@RequestMapping(value = "/foo/{userId}", method = RequestMethod.POST)
public void doStuff(@PathVariable int userId, @RequestBody(required = false) Stuff.Request pbRequest) {
// Do stuff
}
}
我(简体)protobuf3模式:
syntax = "proto3";
message Request {
int32 data = 1;
}
我的配置有可用的内容协商:
@Configuration
public class ProtobufConfig {
@Bean
ProtobufHttpMessageConverter protobufHttpMessageConverter() {
return new ProtobufHttpMessageConverter();
}
}
一切工作只要请求主体设置了一些字节,就像魅力一样。但是如果只发送默认值,protobuf不会写入任何字节。只要我有一个请求消息,其中包含data = 0
生成的字节只是空的。在应用程序方面,请求主体是null
,并且不会转换为protobuf消息(如果请求正文设置为required = true
,它甚至会引发异常)。 HTTP输入消息根本没有被ProtobufHttpMessageConverter
处理。有办法处理吗?