in dubbo-gateway-extensions/dubbo-gateway-provider/src/main/java/org/apache/dubbo/gateway/provider/SnfDecodeableRpcInvocation.java [64:166]
public Object decode(Channel channel, InputStream input) throws IOException {
ObjectInput in = CodecSupport.getSerialization(serializationType)
.deserialize(channel.getUrl(), input);
this.put(SERIALIZATION_ID_KEY, serializationType);
String dubboVersion = in.readUTF();
request.setVersion(dubboVersion);
setAttachment(DUBBO_VERSION_KEY, dubboVersion);
String path = in.readUTF();
setAttachment(PATH_KEY, path);
String version = in.readUTF();
setAttachment(VERSION_KEY, version);
setMethodName(in.readUTF());
String desc = in.readUTF();
setParameterTypesDesc(desc);
ClassLoader originClassLoader = Thread.currentThread().getContextClassLoader();
try {
Object[] args = DubboCodec.EMPTY_OBJECT_ARRAY;
Class<?>[] pts = DubboCodec.EMPTY_CLASS_ARRAY;
if (desc.length() > 0) {
pts = drawPts(path, version, desc, pts);
if (pts == DubboCodec.EMPTY_CLASS_ARRAY) {
// Service not found ,pts = JavaBeanDescriptor
pts = ReflectUtils.desc2classArray(desc);
}
args = drawArgs(in, pts);
}
setParameterTypes(pts);
setAttachment(ORIGIN_GENERIC_PARAMETER_TYPES, pts);
Map<String, Object> map = in.readAttachments();
Class<?>[] retryPts = null;
if (CollectionUtils.isNotEmptyMap(map)) {
if (map.containsKey(ORIGIN_PARAMETER_TYPES_DESC)) {
String originParameterTypesDesc = map.get(ORIGIN_PARAMETER_TYPES_DESC).toString();
retryPts = drawPts(path, version, originParameterTypesDesc, DubboCodec.EMPTY_CLASS_ARRAY);
boolean snf = (retryPts == DubboCodec.EMPTY_CLASS_ARRAY) && !RpcUtils.isGenericCall(originParameterTypesDesc, getMethodName()) && !RpcUtils.isEcho(originParameterTypesDesc, getMethodName());
if (snf) {
setAttachment(OmnipotentCommonConstants.ORIGIN_PATH_KEY, getAttachment(PATH_KEY));
// Replace serviceName in req with omn
setAttachment(PATH_KEY, DEFAULT_OMNIPOTENT_SERVICE);
setAttachment(INTERFACE_KEY, DEFAULT_OMNIPOTENT_SERVICE);
// version
setAttachment(OmnipotentCommonConstants.ORIGIN_VERSION_KEY, getAttachment(VERSION_KEY));
setAttachment(VERSION_KEY, DEFAULT_VERSION);
// method
setAttachment(OmnipotentCommonConstants.ORIGIN_METHOD_KEY, getMethodName());
setAttachment(METHOD_KEY, $INVOKE_OMN);
setMethodName($INVOKE_OMN);
setParameterTypes(new Class<?>[]{Invocation.class});
// Omn needs to use the default path, version and group,
// and the original value starts with origin to save the variable
map.remove(PATH_KEY);
map.remove(VERSION_KEY);
if (map.containsKey(GROUP_KEY)) {
map.put(ORIGIN_GROUP_KEY, map.get(GROUP_KEY));
map.remove(GROUP_KEY);
}
retryPts = (Class<?>[]) getObjectAttachments().get(ORIGIN_GENERIC_PARAMETER_TYPES);
}
}
addObjectAttachments(map);
}
boolean isConvert = false;
for (Class<?> clazz : pts) {
if (clazz == JavaBeanDescriptor.class) {
isConvert = true;
break;
}
}
// isConvert = snf
if (isConvert) {
setParameterTypes(retryPts);
pts = retryPts;
Object[] newArgs = new Object[args.length];
for (int i = 0; i < args.length; i++) {
if (args[i] instanceof JavaBeanDescriptor) {
newArgs[i] = JavaBeanSerializeUtil.deserialize((JavaBeanDescriptor) args[i]);
}
}
args = newArgs;
}
decodeArgument(channel, pts, args);
} catch (ClassNotFoundException e) {
throw new IOException(StringUtils.toString("Read invocation data failed.", e));
} finally {
Thread.currentThread().setContextClassLoader(originClassLoader);
if (in instanceof Cleanable) {
((Cleanable) in).cleanup();
}
}
return this;
}