flatbuffer对象在netty bytebuffer上返回null

发布于 2025-01-29 00:42:10 字数 633 浏览 4 评论 0原文

我们正在使用带有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文