fix(backend-java): 收口并发资源与恢复链路
This commit is contained in:
+9
-1
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user