Fix alibaba Filter / Result Compact (#12440)

This commit is contained in:
Albumen Kevin 2023-06-01 15:43:07 +08:00 committed by GitHub
parent f750b66a31
commit 057dcb4512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -18,6 +18,9 @@
package com.alibaba.dubbo.rpc;
import org.apache.dubbo.rpc.AsyncRpcResult;
import org.apache.dubbo.rpc.AttachmentsAdapter;
import java.util.Map;
@Deprecated
public interface Filter extends org.apache.dubbo.rpc.Filter {
@ -27,7 +30,7 @@ public interface Filter extends org.apache.dubbo.rpc.Filter {
@Override
default org.apache.dubbo.rpc.Result invoke(org.apache.dubbo.rpc.Invoker<?> invoker,
org.apache.dubbo.rpc.Invocation invocation)
throws org.apache.dubbo.rpc.RpcException {
throws org.apache.dubbo.rpc.RpcException {
Result invokeResult = invoke(new Invoker.CompatibleInvoker<>(invoker),
new Invocation.CompatibleInvocation(invocation));
@ -38,6 +41,10 @@ public interface Filter extends org.apache.dubbo.rpc.Filter {
AsyncRpcResult asyncRpcResult = AsyncRpcResult.newDefaultAsyncResult(invocation);
asyncRpcResult.setValue(invokeResult.getValue());
asyncRpcResult.setException(invokeResult.getException());
Map<String, String> attachments = invokeResult.getAttachments();
if (!(attachments instanceof AttachmentsAdapter.ObjectToStringMap)) {
asyncRpcResult.setAttachments(attachments);
}
asyncRpcResult.setObjectAttachments(invokeResult.getObjectAttachments());
return asyncRpcResult;

View File

@ -64,6 +64,16 @@ public interface Result extends org.apache.dubbo.rpc.Result {
return null;
}
/**
* @see com.alibaba.dubbo.rpc.Result#getValue()
* @deprecated Replace to getValue()
*/
@Deprecated
default Object getResult() {
return getValue();
}
class CompatibleResult implements Result {
private org.apache.dubbo.rpc.Result delegate;