You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2022/06/10 04:06:56 UTC
[GitHub] [incubator-brpc] lzfhust commented on a diff in pull request #1790: Thrift protocol exception
lzfhust commented on code in PR #1790:
URL: https://github.com/apache/incubator-brpc/pull/1790#discussion_r894135011
##########
src/brpc/policy/thrift_protocol.cpp:
##########
@@ -132,35 +132,38 @@ bool ReadThriftStruct(const butil::IOBuf& body,
::apache::thrift::transport::TMemoryBuffer::TAKE_OWNERSHIP);
apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TMemoryBuffer> iprot(in_buffer);
- // The following code was taken from thrift auto generate code
- std::string fname;
-
- uint32_t xfer = 0;
- ::apache::thrift::protocol::TType ftype;
- int16_t fid;
-
- xfer += iprot.readStructBegin(fname);
bool success = false;
- while (true) {
- xfer += iprot.readFieldBegin(fname, ftype, fid);
- if (ftype == ::apache::thrift::protocol::T_STOP) {
- break;
- }
- if (fid == expected_fid) {
- if (ftype == ::apache::thrift::protocol::T_STRUCT) {
- xfer += raw_msg->Read(&iprot);
- success = true;
+ try {
+ // The following code was taken from thrift auto generate code
+ std::string fname;
+
+ uint32_t xfer = 0;
+ ::apache::thrift::protocol::TType ftype;
+ int16_t fid;
+ xfer += iprot.readStructBegin(fname);
+ while (true) {
+ xfer += iprot.readFieldBegin(fname, ftype, fid);
+ if (ftype == ::apache::thrift::protocol::T_STOP) {
+ break;
+ }
+ if (fid == expected_fid) {
+ if (ftype == ::apache::thrift::protocol::T_STRUCT) {
+ xfer += raw_msg->Read(&iprot);
+ success = true;
+ } else {
+ xfer += iprot.skip(ftype);
+ }
} else {
xfer += iprot.skip(ftype);
}
- } else {
- xfer += iprot.skip(ftype);
+ xfer += iprot.readFieldEnd();
}
- xfer += iprot.readFieldEnd();
- }
- xfer += iprot.readStructEnd();
- iprot.getTransport()->readEnd();
+ xfer += iprot.readStructEnd();
+ iprot.getTransport()->readEnd();
+ } catch (...) {
Review Comment:
好的,增加了几种exception的打印。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org