fix(haobang-security-rule)修改json错误处理方式
This commit is contained in:
+4
-13
@@ -72,19 +72,10 @@ public class NestedJsonParserUtil {
|
||||
return postProcessParsedData(result, maxDepth);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.warn("JSON解析失败,长度={}, 原因={}", jsonStr.length(), e.getMessage());
|
||||
|
||||
// 5. 尝试修复并重新解析
|
||||
try {
|
||||
String fixedJson = tryFixNestedJson(jsonStr, maxDepth);
|
||||
if (!fixedJson.equals(jsonStr)) {
|
||||
TypeReference<Map<String, Object>> typeRef = new TypeReference<Map<String, Object>>() {};
|
||||
Map<String, Object> result = objectMapper.readValue(fixedJson, typeRef);
|
||||
return postProcessParsedData(result, maxDepth);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.debug("JSON修复后解析仍然失败: {}", ex.getMessage());
|
||||
}
|
||||
// 标准化主链路不再对坏 JSON 做猜测修复:失败后由上层直接转非标。
|
||||
// getMessage() 会附带 Source 原文片段,大量异常报文会放大 Docker 日志 I/O;
|
||||
// 仅在 DEBUG 保留不含原文的 Jackson 原始错误。
|
||||
logger.debug("JSON解析失败,长度={}, 原因={}", jsonStr.length(), e.getOriginalMessage());
|
||||
return null;
|
||||
//return Collections.emptyMap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user