Comments (10)
这是一个特性
发自我的 iPad
在 2014年12月30日,下午4:59,eligo [email protected] 写道:
optional int32 的字段如果赋值为0, encode 的时候好像没有把这个字段encode 进去, decode的时候也没有应字段的值
—
Reply to this email directly or view it on GitHub.
from pbc.
这是个问题额....
from pbc.
在嵌套的协议上面,这是个比较严重的问题额~
message msgone
{
optional int32 msg1aid = 1;
optional int32 msg1bid = 2;
optional int32 msg1cid = 3;
}
message msgtwo
{
optional int32 msg2aid = 1;
optional int32 msg2bid = 2;
optional int32 msg2cid = 3;
repeated msgthree msgthreeAry = 4;
}
message msgthree
{
optional int32 msg3aid = 1;
optional int32 msg3bid = 2;
optional int32 msg3cid = 3;
}
message request6789
{
optional int32 pid = 1;
optional int32 arg1 = 2;
repeated msgone argOneArray = 3;
optional msgtwo argTwo = 4;
}
如果message msgtwo这里的msgthreeAry里放的是0值的msgthree,
这样msgthree会被忽略掉,但是msgthreeAry的数组,业务上是认为有这个数据的
最后就会导致另一端解析出错。
所以应该是个BUG,而不是特性
from pbc.
在 repeated 里,msgthree 并不会被忽略。只有 optional 的才会。
from pbc.
我填数据测试,将repeated msgthree msgthreeAry 里的msgthree3个值都设置为0,这时候会被忽略掉。
local msgone_arg={}
for i=1,3 do
local msgtOne ={}
msgtOne.msg1aid =1
msgtOne.msg1bid =1
msgtOne.msg1cid =1
msgone_arg[#msgone_arg+1]=msgtOne
end
local msgthreeAry ={}
for i=1,3 do
local msgthree ={}
msgthree.msg3aid=0 --这里设置为0
msgthree.msg3bid=0 --这里设置为0
msgthree.msg3cid=0 --这里设置为0
msgthreeAry[#msgthreeAry+1]=msgthree
end
local argTwo_arg ={}
argTwo_arg.msg2aid=2
argTwo_arg.msg2bid=2
argTwo_arg.msg2cid=2
argTwo_arg.msgthreeAry = msgthreeAry
local tabPak={
arg1 = 100,
argOneArray = msgone_arg,
argTwo = argTwo_arg,
}
from pbc.
应该说repeated标记msgthreeAry不会被忽略,但是因为它的元素是optional int32的,会被忽略掉
就是导致有数组,但是没有数据,从而在另外一端java解析的时候会解析出错。
是在哪里忽略的?能告诉个范围位置,然后我去掉这个特性试试不?
from pbc.
这是bug, 因为这样做跟其他客户端不兼容了.
from pbc.
不兼容的话,请把其它客户端改对。
from pbc.
这个算是BUG,因为protobuf有一种惯例用法:has_field(),用于判断是否设置了这个字段。实际工作中当作NULL来使用的
也就是说,field=0 和 不set field,field的值都是0,但是has_field不同
from pbc.
has_field 是实现加的东西,不是规范定义的。所谓惯用法指的特定实现的惯用法。这个版本的实现没有这个惯用法。
protobuf 为数据结构定义了类型,对于整数类型来说,NULL 不是个有效值。把 has_field 作为常规用法是一种滥用。这个特性可以纠正这种滥用。
from pbc.
Related Issues (20)
- pbc_wmessage_integer
- mac os 上make命令不能执行 HOT 1
- 在 Mac 直接编译项目提供的 Demo,直接提示下面错误,大神能给看一下吗
- pbc_array_push_slice() bug?
- ubuntu+skynet+pbc环境,encode一个包含了int32类型的数据,会报错。但是改成了类型就不会了.
- skyent 加了一个protobuf 第一次运行报错了。 风哥看看这是啥原因啊 HOT 5
- protobuf 编译如何链接lua5.4,风哥是否能说的稍微详细一些。 HOT 3
- 最新版skynet里调用报错 HOT 3
- pbc是否支持protobuf3的any类型
- PBC library generate a BN256 curve
- enum 类型在 lua 层会被解析为 字符串呢?
- 是否支持grpc呢
- Error : rmessage decode context error HOT 2
- 是否能支持protobuf 3
- 编译binding/lua53时报错 HOT 3
- 在lua中修改的uint64字段字段,经过一次encode之后,又变回了原来的值,感觉没有修改成功,请云风大大看看怎么回事哈 HOT 1
- mingw环境下编译pbc的lua绑定库protobuf会出怪异现象,引用的skynet里lua5.4版本: HOT 5
- SEGV issue detected in pbc_wmessage_integer src/wmessage.c:137
- PBC有非Lazy的解析接口吗
- SEGV issue detected in pbc_wmessage_string src/wmessage.c:281:8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pbc.