Skip to content

Commit

Permalink
add serialization check (#14312)
Browse files Browse the repository at this point in the history
  • Loading branch information
icodening authored Jun 12, 2024
1 parent 5d5d036 commit e4fa369
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import org.apache.dubbo.remoting.http12.exception.EncodeException;
import org.apache.dubbo.remoting.http12.message.HttpMessageCodec;
import org.apache.dubbo.remoting.http12.message.MediaType;
import org.apache.dubbo.remoting.transport.CodecSupport;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.protocol.tri.TripleConstant;
import org.apache.dubbo.rpc.protocol.tri.TripleCustomerProtocolWapper;

import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -112,6 +114,8 @@ public Object[] decode(InputStream inputStream, Class<?>[] targetTypes, Charset
}
TripleCustomerProtocolWapper.TripleRequestWrapper wrapper =
TripleCustomerProtocolWapper.TripleRequestWrapper.parseFrom(bos.toByteArray());
final String serializeType = convertHessianFromWrapper(wrapper.getSerializeType());
CodecSupport.checkSerialization(serializeType, url);
setSerializeType(wrapper.getSerializeType());
Object[] ret = new Object[wrapper.getArgs().size()];
for (int i = 0; i < wrapper.getArgs().size(); i++) {
Expand Down Expand Up @@ -140,4 +144,11 @@ private static void writeLength(OutputStream outputStream, int length) throws IO
outputStream.write(((length >> 8) & 0xFF));
outputStream.write((length & 0xFF));
}

private static String convertHessianFromWrapper(String serializeType) {
if (TripleConstant.HESSIAN4.equals(serializeType)) {
return TripleConstant.HESSIAN2;
}
return serializeType;
}
}

0 comments on commit e4fa369

Please sign in to comment.