fix(codec): 解码映射失败产出 CODEC_ERROR,落实退避重试与可重放白名单

This commit is contained in:
windyboy
2026-09-11 14:25:42 +08:00
parent fed0b5df26
commit d909a88167
2 changed files with 29 additions and 0 deletions
@@ -1,6 +1,7 @@
package com.gzzn.omms.msgexchange.codec
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import com.fasterxml.jackson.dataformat.xml.XmlFactory
import com.fasterxml.jackson.dataformat.xml.XmlMapper
@@ -34,6 +35,14 @@ class JacksonXmlCodec : XmlCodec {
}
val msg = try {
mapper.readValue(trimmed, SisMessageXml::class.java)
} catch (e: JsonMappingException) {
// META 层绑定失败=发送方违反必填契约(MALFORMED);体层(SCHD/FLOP)结构不匹配
// =wire 结构超出编解码器当前绑定能力(CODEC_ERROR:退避重试,修复后可重放,design §2.3)。
val first = e.path.firstOrNull()?.fieldName ?: ""
if (first.equals("meta", ignoreCase = true)) {
return DecodeResult.Err(DecodeFailure(ErrorClass.MALFORMED, "xml-meta:${e.originalMessage.take(200)}"))
}
return DecodeResult.Err(DecodeFailure(ErrorClass.CODEC_ERROR, "xml-mapping:${e.originalMessage.take(200)}"))
} catch (e: Exception) {
return DecodeResult.Err(
DecodeFailure(ErrorClass.MALFORMED, "xml-parse:${e.message?.take(200) ?: e.javaClass.simpleName}"),