AlexStocks commented on code in PR #43:
URL: https://github.com/apache/dubbo-net/pull/43#discussion_r4642453168


##########
DubboService/Native/NativeDubboCodec.cs:
##########
@@ -303,9 +308,29 @@ internal static DubboInvocation ParseInvocation(string 
endPoint, string request)
             return new DubboInvocation(service, method, parameterTypes, 
arguments);
         }
 
-        internal static string SerializeJson(object value)
+        internal static string SerializeJson(object value, int payloadLength = 
0)

Review Comment:
   [P2] `payloadLength = 0` 这个默认值,就是这轮修复的复发入口
   
   预算是 `payloadLength` 的纯函数:
   
   ```csharp
   _nodeLimit     = min(2_000_000, max(100_000, 2 * payloadLength))
   _jsonByteLimit = min(64 MiB,   max(32 MiB,  8 * payloadLength))
   ```
   
   `payloadLength = 0` 代入即得**下限** 100,000 节点 / 32 MiB —— 正好等于本 PR 之前 event 
分支的取值。本 PR 的修法本质是「让调用方把真实 body 长度传进来」,但只要默认值还在,下一个新增的响应路径就能在编译期合法地拿回旧行为,且没有任何提示。
   
   当前调用面(head 实测):
   
   - 生产侧只有 3 处:`NativeDubboActuatorSuite.cs:207` 显式传 
`response.PayloadLength`;`:213`、`:219` 走 
`SerializeResponseJson`(内部已处理)。**没有任何生产调用方依赖默认值。**
   - 测试侧 4 处单参调用:`SerializeJson(unit)`、`SerializeJson(values)`(出现在 
`UnpairedSurrogateStringsCannotBypassJsonSizeBudget`、`AlternatingStringsConsumeTheirOwnJsonSizeBudget`、`SendQuery_LargeProtocolErrorUsesTheBodySizedJsonBudget`)。改成必填的代价就是这
 4 处各补一个参数。
   
   还有一个让「落到下限」后果变重的因素:`StringBytes` 这次从「UTF-16 最坏转义 6 字节/码元」改成按实际 UTF-8 + 
转义计费(README 新旧文案对应 `strings are estimated using the worst-case escaped size of 
UTF-16 characters` → `String accounting follows UTF-8 lengths`)。对纯 ASCII,同样的 32 
MiB 预算从约 559 万字符放宽到约 3,354 万字符(约 6 倍)。这不影响本 PR 的正确性,但它意味着一旦有人踩到默认值,宽松程度比 main 
高一个量级——更值得让编译器挡一次,而不是靠文档提醒。
   
   建议:删掉 `= 0`,让 4 处测试调用显式传值。
   



-- 
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]

Reply via email to