flatbuffer对象在netty bytebuffer上返回null
我们正在使用带有Java绑定的FlatBuffer。 该应用程序正在运行NetTy4,并且具有以下代码来处理Netty请求:
String id;
try {
request = PostRequest.getRootAsPostRequest(msg.getPayloadBuffer().nioBuffer());
id = request.id(); // string
} catch (final Exception exception) {
ctx.writeResponseAndFlush(StatusCode.StatusCode400, exception);
return;
} finally {
msg.getPayloadBuffer().release();
}
traceId = request.traceId(); // <-- this string sometimes becomes null
此代码偶尔将TraceID
作为null设置,我无法完全理解原因。 是因为我正在用释放
块时,基础缓冲区可能已经发布和重复使用?
即使那样,为什么它只会很少和并非总是如此?
We are using Flatbuffer with Java bindings.
The application is running Netty4 and has following code for handling Netty request:
String id;
try {
request = PostRequest.getRootAsPostRequest(msg.getPayloadBuffer().nioBuffer());
id = request.id(); // string
} catch (final Exception exception) {
ctx.writeResponseAndFlush(StatusCode.StatusCode400, exception);
return;
} finally {
msg.getPayloadBuffer().release();
}
traceId = request.traceId(); // <-- this string sometimes becomes null
This code occasionally sets traceId
as null and I am not able to fully understand why.
Is it because the underlying buffer might have been release and reused as I am releasing it in finally
block?
Even then, why does it happen only rarely and not always?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论