AlexStocks commented on code in PR #139:
URL: https://github.com/apache/dubbo-getty/pull/139#discussion_r3718285039
##########
session_test.go:
##########
@@ -32,6 +32,48 @@ func (errorReader) Read(Session, []byte) (any, int, error) {
return nil, 0, errTestReadFailure
}
+func TestUDPReadBufferLen(t *testing.T) {
+ tests := []struct {
+ name string
+ maxMsgLen int32
+ want int64
+ }{
+ {
+ name: "negative max message length uses default
read buffer",
+ maxMsgLen: -1,
+ want: int64(maxReadBufLen),
+ },
+ {
+ name: "zero max message length uses default read
buffer",
+ maxMsgLen: 0,
+ want: int64(maxReadBufLen),
+ },
+ {
+ name: "small max message length caps buffer at
twice max message length",
+ maxMsgLen: 1,
+ want: 2,
+ },
+ {
+ name: "default max message length allows one extra
read buffer",
+ maxMsgLen: maxReadBufLen,
+ want: int64(maxReadBufLen * 2),
+ },
+ {
+ name: "larger max message length adds one read
buffer",
+ maxMsgLen: maxReadBufLen * 2,
Review Comment:
[P1] 覆盖实际导致 386 溢出的最大边界
当前表格最大输入只有 8192,无法触发本轮修复的 32 位 `int` 溢出。我在 exact Head 的隔离变异中把 helper 恢复为错误的
`int` 加法/左移后,`GOARCH=386 TestUDPReadBufferLen` 仍连续 20 次通过;只有加入 `math.MaxInt32`
边界才暴露结果为 `-2147479553`(正确值 `2147487743`)。这说明现有测试不能防止本次 Bug 回归。请补 MaxInt32 边界并让
CI 在 GOARCH=386 执行;最好再覆盖 `handleUDPPackage` 的 `exceeds max int`
受控错误,避免测试只验证公式而遗漏 `int64 -> int` 转换门禁。
--
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]