AlexStocks commented on code in PR #43:
URL: https://github.com/apache/dubbo-net/pull/43#discussion_r4578018513
##########
DubboService/Native/NativeDubboCodec.cs:
##########
@@ -308,6 +312,24 @@ internal static string SerializeJson(object value)
return JsonSerializer.Serialize(ToJsonCompatible(value),
ResultJsonOptions);
}
+ /// <summary>
+ /// 将已解码且未修改的成功状态响应输出为 JSON;普通返回值和异常已完成规范化检查。
+ /// <para>EN: Serializes an unmodified OK-status response returned by
DecodeResponse.
+ /// Ordinary values and exceptions have already been normalized and
budget-checked;
+ /// event values still use the checked serialization path.</para>
+ /// </summary>
+ internal static string SerializeResponseJson(NativeDubboResponse
response)
+ {
+ object value = response.Exception ?? response.Value;
+
+ if (response.IsEvent)
+ {
+ return SerializeJson(value);
Review Comment:
[P2] event 值的展开预算仍固定为 100,000 节点 / 32 MiB,与新增的 bodyBytes 公式不一致
**触发条件**:provider 发来 event 帧(`IsEvent == true`)且其 value 超过 100,000 个展开节点(或估算
JSON 超过 32 MiB);同一 payload 作为普通响应时,只要 body ≥ 1 MiB 就会被放宽到 2,000,000 节点 / 64 MiB。
**实际影响**:非 event 响应走本 PR 新增的“已预算化、直接序列化”路径,event 响应则回落到 `SerializeJson`,后者用
`payloadLength: 0` 重建预算,即固定取公式下限。于是同一份 1 MiB、12 万节点的 payload:普通响应被接受,event 响应抛
`Hessian2 response expansion exceeds the limit of 100000 nodes`。README 与
readme_cn 新增的公式 `min(2_000_000, max(100_000, 2 * bodyBytes))` 未写明该例外,按文档估算
event 容量会得到错误结论。实际业务中 event 值通常为 null,因此影响面有限,但两者判据不一致是本次引入的。
**证据**(当前 head `9dd3c1db`,源码级判断):
- `NativeDubboCodec.DecodeResponse` 对 `frame.IsEvent` 直接 `response.Value =
input.ReadValue()` 后 return,不建立 `NormalizationBudget`。
- `SerializeResponseJson` 第 325-327 行:event 分支 `return
SerializeJson(value)`;第 330 行非 event 分支直接 `JsonSerializer.Serialize`。
- `SerializeJson` 第 312 行 → `ToJsonCompatible(value)` 第 852 行 `budget ?? new
NormalizationBudget(payloadLength: 0)`,即 `_nodeLimit = 100_000`、`_jsonByteLimit
= 32 MiB`。
- README「native actuator boundaries」段只按 `bodyBytes` 描述两档预算,未区分 event。
**修复方向**:让 event 分支复用响应体的 `payloadLength`(把 body 长度带到 `NativeDubboResponse`
或 `SerializeResponseJson` 签名中)以保持同一判据;若有意对 event 保持保守取值,请在 README 与 readme_cn
的边界段显式注明 event 值固定使用 100,000 节点 / 32 MiB 下限。
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]