小编YU *_*ang的帖子

Apache Thrift:在列表之前使用"可选"时,C++服务器似乎不能正确返回它

嗨!每一个,我都有类似这个问题:

关于节俭功能返回列表

当列表具有"可选"修饰符时,thrift C++服务器将始终将其作为null/undef返回.

此外,如果可选列表包含的结构,任何结构的字段,都不能设置为"可选",或者将返回null/undef值.

删除所有"可选"修饰符后,一切正常.

谁能告诉我为什么我不能在列表前使用"可选"?


这是节俭文件:

namespace cpp thrifttest
namespace perl thrifttest

struct Pair {
    1: optional string a, 
    2: optional string b
}

struct Result {
    1: optional list<string> strList,
    2: optional list<Pair> pairList
}

service Test {

    Result listTest()

}
Run Code Online (Sandbox Code Playgroud)

这是C++代码(服务器):

#include "gen-cpp/Test.h"
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/server/TSimpleServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TBufferTransports.h>

#include <iostream>

using namespace std;

using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
using namespace ::apache::thrift::server;

using boost::shared_ptr;

using namespace  ::thrifttest;

class TestHandler …
Run Code Online (Sandbox Code Playgroud)

c++ perl thrift

2
推荐指数
1
解决办法
1316
查看次数

标签 统计

c++ ×1

perl ×1

thrift ×1