Pre-check
- [x] I am sure that all the content I provide is in English.
Search before asking
- [x] I had searched in the issues and found no similar issues.
Apache Dubbo Component
Java SPI Extensions (apache/dubbo-spi-extensions)
Dubbo Version
Dubbo Java 3.3.0 oracle jdk 17
Steps to reproduce this issue
- my rest api
```java
@PostMapping("addUser")
public R
addUser(@RequestBody UserParam user) { return R.ok(user); }
2. my dubbo interface
```java
@PostMapping(value = "addUser", consumes = MediaType.APPLICATION_JSON_VALUE)
R<UserParam> addUser(@RequestBody UserParam user);
- FormConsumerParamParser parses parameters after BodyConsumerParamParser in the resolution order.
- Finally, JsonUtils.toJson produced an incorrect request body.
What you expected to happen
FormConsumerParamParser should not support @RequestBody
Anything else
No response
Are you willing to submit a pull request to fix on your own?
- [x] Yes I am willing to submit a pull request on my own!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Comment From: AlbumenJ
@oxsean PTAL
Comment From: oxsean
@Godfunc The BodyConsumerParamParser you mentioned should be part of the old REST protocol used before version 3.2.0. It is recommended to upgrade to the latest Triple REST after version 3.3.0 https://dubbo.apache.org/zh-cn/overview/mannual/java-sdk/tasks/protocols/rest/
Comment From: Godfunc
@oxsean
My provider is a REST API that does not use the Dubbo framework. I'm trying to use org.apache.dubbo.extensions:dubbo-rpc-rest
to call the provider's REST endpoints. Since Triple REST requires the provider to integrate the Dubbo framework, it doesn't suit my use case, so dubbo-rpc-rest
seems to be my only option.
However, FormConsumerParamParser
supports parameters annotated with @RequestBody
, which causes it to process the request parameters and ultimately results in an incorrect request JSON.
public enum ParamType {
FORM(addSupportTypes(
JAXRSClassConstants.FORM_PARAM_ANNOTATION_CLASS,
JAXRSClassConstants.FORM_BODY_ANNOTATION_CLASS,
SpringMvcClassConstants.REQUEST_BODY_ANNOTATION_CLASS)), // replace with REQUEST_PARAM_ANNOTATION_CLASS
...
}
Comment From: oxsean
@Godfunc you can try to fix it.
Comment From: Godfunc
@oxsean PR [dubbo-metadata-rest]fix: update ParamType.FORM supported annotations