fix(backend-java): 收口并发资源与恢复链路

This commit is contained in:
2026-09-05 14:33:07 +08:00
parent d760838e71
commit 40224d8e56
35 changed files with 917 additions and 154 deletions
@@ -105,7 +105,15 @@ public class TaskOwnerForwardService {
private static byte[] requestBody(HttpServletRequest request) {
if (request instanceof ContentCachingRequestWrapper wrapper) {
byte[] body = wrapper.getContentAsByteArray();
return body == null ? new byte[0] : body;
byte[] safeBody = body == null ? new byte[0] : body;
long declaredLength = request.getContentLengthLong();
if (safeBody.length >= 1024L * 1024L
&& declaredLength >= 0L && declaredLength > safeBody.length) {
// ContentCachingRequestWrapper 超过缓存上限时会静默截断,不能把不完整
// 的请求转发到归属实例,否则可能造成 JSON/批量回调数据损坏。
throw new BusinessException("请求体超过实例转发缓存上限,无法安全转发");
}
return safeBody;
}
try {
return StreamUtils.copyToByteArray(request.getInputStream());