org.apache.dubbo.rpc.filter.GenericFilter#gson field need support customization
- Dominant language
- Java
- Stars
- 41.6k
- Forks
- 26.4k
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 4
Description
- [x] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
- [x] I have searched the [release notes](https://github.com/apache/dubbo/releases) of this repository and believe that this is not a duplicate.
## Describe the feature
We used the gson generalization call provided by dubbo, but this gson does not provide custom deserialization capabilities, we want to call `new GsonBuilder() .registerTypeAdapter()...create()` because we provide parameters and return The values are all interface types.
code like below:
```java
public interface Request extends Serializable {
T getRequestData();
}
public interface Result extends Serializable {
T getData();
Result setData(T data);
}
//provider
// dubbo v3.0.7
@Override
public Result addExperiment(Request request) {
Mono m = a.a(request.getRequestData())
.onErrorMap(throwable -> Exceptions.fromCode(0,"失败!")
.then();
return CompletableResults.wrapMono(m);
}
//consumer
// dubbo v3.0.5
protected void initRefConfig() {
ReferenceConfig refConfig = new ReferenceConfig<>();
refConfig.setInterface(serviceName);
refConfig.setGeneric("gson");
refConfig.setAsync(true);
refConfig.setProtocol(protocol.getProtocol());
refConfig.setVersion("*");
refConfig.setCheck(false);
refConfig.setRetries(3);
}
//consumer invoke async
public void invoke(Params params, MonoSink sink) {
//getService() = refConfig.get();
getService().$invokeAsync(params.getMethod(), new String[]{"Request.class"}, new Object[]{"{\"requestData\":{}}"})
.whenComplete(((o, throwable) -> {
if (isNull(throwable)) {
sink.success(o);
} else {
sink.error(throwable);
}
}));
}
```
Expect to provide a good solution instead of customizing a Filter to replace the GenericFilter.
Contributor guide
Assessment
This issue has not been assessed yet.