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/11 03:05:46 UTC
[GitHub] [incubator-brpc] jamesge commented on a diff in pull request #1790: Thrift protocol exception
jamesge commented on code in PR #1790:
URL: https://github.com/apache/incubator-brpc/pull/1790#discussion_r894968534
##########
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:
建议修改为”Catched thrift 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