HY-love-sleep opened a new pull request, #7138: URL: https://github.com/apache/shenyu/pull/7138
### 修复的问题 - Closes #6513 - Closes #6514 - Closes #6515 ### 改动说明 **#6513 规则字段为 null 导致请求处理崩溃** 真实崩溃点是 `isAllowed()` 里 `>= tokenLimit` 的 null 拆箱、以及 `recordTokensUsage()` 里的 `Duration.ofSeconds(null)`。 在 `AiTokenLimiterPluginHandler.handlerRule()` 中复用 `AiTokenLimiterHandle.newDefaultInstance()` 补默认值,与 admin 新建规则时的默认保持一致。 **#6514 Redis 计数 key 未按 selector / rule 隔离** key 从 `PREFIX + resolverValue` 改为 `PREFIX + CacheKeyUtils.INST.getKey(rule) + ":" + resolverValue`,复用与 handle 缓存同源的规则 key。 注意:key 格式变更,**存量计数器会保留旧 key 并在时间窗口后自然过期**。 **#6515 gzip 响应跨 DataBuffer 时漏算 token** 原实现手工定位 gzip 头,并假设整个 header 都在第一个 DataBuffer 内;当 header 跨 buffer 边界时偏移算错,负载根本没被解析。 新增包级可见的 `GzipStreamDecoder`:`GzipHeaderState` 跨 buffer 解析 gzip 头(支持 FEXTRA/FNAME/FCOMMENT/FHCRC),配合 `Inflater` 增量解压,**内存有界**,与 #7124 的 `BodyWriter` 方向一致。 ### 已知限制 - 不支持 multi-member gzip(解完第一个 deflate 流后停止) - gzip 头超过 266 字节时放弃解压并打一条 WARN ### 测试 7 个用例:头跨 buffer、头在同一 buffer、**首块远大于头缓冲上限(266)的回归用例**、多块端到端解压(精确字符串比对)、规则空值填充。 本地 `./mvnw -pl shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-token-limiter -am test` 通过,checkstyle 0 违规。 -- 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]
