lzfhust commented on code in PR #1790:
URL: https://github.com/apache/incubator-brpc/pull/1790#discussion_r894971286
##########
src/brpc/policy/thrift_protocol.cpp:
##########
@@ -132,35 +132,40 @@ 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 (std::exception& e) {
+ LOG(WARNING) << "In read thrift struct, catched exception:" <<
e.what();
+ } catch (...) {
+ LOG(WARNING) << "In read thrift struct, catched unknown exception";
Review Comment:
谢谢指正。已修改
##########
src/brpc/policy/thrift_protocol.cpp:
##########
@@ -132,35 +132,40 @@ 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 (std::exception& e) {
+ LOG(WARNING) << "In read thrift struct, catched exception:" <<
e.what();
Review Comment:
谢谢指正。已修改
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]