Skip to content

Commit da5c7ed

Browse files
authored
Fix generic array being changed (#13103)
1 parent 0fb1e4c commit da5c7ed

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ public Object decode(Channel channel, InputStream input) throws IOException {
158158
pts = drawPts(path, version, desc, pts);
159159
if (pts == DubboCodec.EMPTY_CLASS_ARRAY) {
160160
if (RpcUtils.isGenericCall(desc, getMethodName())) {
161-
pts = DubboCodec.GENERIC_PTS_ARRAY;
161+
// Should recreate here for each invocation because the parameterTypes may be changed by user.
162+
pts = new Class<?>[]{String.class, String[].class, Object[].class};
162163
} else if (RpcUtils.isEcho(desc, getMethodName())) {
163-
pts = DubboCodec.ECHO_PTS_ARRAY;
164+
pts = new Class<?>[]{Object.class};
164165
} else {
165166
throw new IllegalArgumentException("Service not found:" + path + ", " + getMethodName());
166167
}

dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboCodec.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ public class DubboCodec extends ExchangeCodec {
6969
public static final byte RESPONSE_NULL_VALUE_WITH_ATTACHMENTS = 5;
7070
public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
7171
public static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
72-
public static final Class<?>[] GENERIC_PTS_ARRAY = new Class<?>[]{String.class, String[].class, Object[].class};
73-
public static final Class<?>[] ECHO_PTS_ARRAY = new Class<?>[]{Object.class};
7472
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(DubboCodec.class);
7573

7674
private static final AtomicBoolean decodeInUserThreadLogged = new AtomicBoolean(false);

0 commit comments

Comments
 (0)