Skip to content

Commit 21e6491

Browse files
qinliujiechickenlj
authored andcommitted
修复 invocation 不能传递 attributes 的问题 (#4024)
1 parent ebe3e42 commit 21e6491

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ public RpcInvocation(Method method, Object[] arguments) {
9191
this(method.getName(), method.getParameterTypes(), arguments, null, null);
9292
}
9393

94-
public RpcInvocation(Method method, Object[] arguments, Map<String, String> attachment) {
94+
public RpcInvocation(Method method, Object[] arguments, Map<String, String> attachment, Map<Object, Object> attributes) {
9595
this(method.getName(), method.getParameterTypes(), arguments, attachment, null);
9696
this.returnType = method.getReturnType();
97+
this.attributes = attributes == null ? new HashMap<>() : attributes;
9798
}
9899

99100
public RpcInvocation(String methodName, Class<?>[] parameterTypes, Object[] arguments) {

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
7979
} else if (ProtocolUtils.isJavaGenericSerialization(generic)) {
8080
for (int i = 0; i < args.length; i++) {
8181
if (byte[].class == args[i].getClass()) {
82-
try(UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[]) args[i])) {
82+
try (UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[]) args[i])) {
8383
args[i] = ExtensionLoader.getExtensionLoader(Serialization.class)
8484
.getExtension(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA)
8585
.deserialize(null, is).readObject();
@@ -111,7 +111,8 @@ public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
111111
}
112112
}
113113
}
114-
return invoker.invoke(new RpcInvocation(method, args, inv.getAttachments()));
114+
115+
return invoker.invoke(new RpcInvocation(method, args, inv.getAttachments(), inv.getAttributes()));
115116
} catch (NoSuchMethodException e) {
116117
throw new RpcException(e.getMessage(), e);
117118
} catch (ClassNotFoundException e) {

0 commit comments

Comments
 (0)