STRICT_DUPLICATE_DETECTION rejects repeated XML elements read by a custom deserializer
まだ誰も着手していません。
評価
調査の方向性
Start with StrictDuplicateDetectionXmlTest and trace FromXmlParser token handling into the duplicate-name check in JsonReadContext, focusing on how repeated XML elements are represented before readValueAsTree() builds the tree. Run the three listed JUnit cases to confirm the failure and controls. Done means the custom-deserializer case with strict detection enabled preserves both OU values while the declared-List and strict-disabled controls still pass.
索引モデルが issue の本文から書いたものです。
説明
Summary
In XML, sibling elements with the same name are legitimate and normally map to a list. When such repeats are bound to a declared List property, STRICT_DUPLICATE_DETECTION correctly tolerates them (they are coalesced into the list). But when the same repeats are consumed by a custom deserializer that materializes the element with JsonParser.readValueAsTree(), enabling STRICT_DUPLICATE_DETECTION makes the read fail with:
tools.jackson.core.exc.StreamReadException: Duplicate Object property "OU"
A repeated XML element is thus reported as a duplicate object property. This makes STRICT_DUPLICATE_DETECTION effectively incompatible with any element whose child tag names are dynamic/heterogeneous and must be read as a tree — a Distinguished Name is the canonical example:
<Dn>
<C>FR</C>
<O>ACME</O>
<OU>Sales</OU>
<OU>EMEA</OU> <!-- legitimate repeat; rejected under STRICT -->
<CN>leaf</CN>
</Dn>
Because the RDN tag names differ (C, O, OU, CN), the element cannot be bound to a single declared List, so a custom deserializer is required — and that path is broken by the feature.
How to reproduce
./gradlew test # the three JUnit cases below
./gradlew run # prints the three cases
run output:
1) declared List + STRICT on -> OK [Sales, EMEA]
2) custom deser + STRICT off -> OK [Rdn[type=C, value=FR], Rdn[type=O, value=ACME], Rdn[type=OU, value=Sales], Rdn[type=OU, value=EMEA], Rdn[type=CN, value=leaf]]
3) custom deser + STRICT on -> FAILS StreamReadException: Duplicate Object property "OU"
StrictDuplicateDetectionXmlTest:
repeatedElementsBoundToDeclaredListAreToleratedUnderStrict— control: declaredList+ STRICT → OK.repeatedElementsViaCustomDeserializerWorkWithoutStrict— control: custom deserializer, STRICT off → OK (both<OU>kept).repeatedElementsViaCustomDeserializerFailUnderStrict— the issue: same input, STRICT on →StreamReadException: Duplicate Object property "OU".
Actual behaviour
STRICT_DUPLICATE_DETECTION fires at the streaming/token level (JsonReadContext duplicate name check) as soon as the second <OU> name is seen, before the XML module coalesces the repeats into an array — so the tree is never built.
Expected behaviour
Reading the element via readValueAsTree() should coalesce the repeated <OU> siblings into an ArrayNode (as it already does when STRICT_DUPLICATE_DETECTION is disabled), rather than reporting them as a duplicate object property. Repeated XML elements are not JSON-style duplicate keys.
Additional information
Within the custom deserializer, every way of consuming the element goes through the strict parser and triggers the same detection: readValueAsTree(), manual nextToken() streaming, @JsonAnySetter, TokenBuffer.copyCurrentStructure(...), and skipChildren(). Reading the underlying Stax XMLStreamReader directly avoids the detection but desynchronises FromXmlParser (one-token lookahead), breaking the outer parse. The feature therefore cannot be kept while deserializing such an element.
A Gradle projet that illustrates this issue is attached to the ticket:
jackson-xml-strict-duplicate-dn-sources.zip
- 主要言語
- Java
- スター
- 636
- フォーク
- 250
- 平均マージ
- 7時間 10分
- マージ済み PR(30日)
- 8
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
FasterXML/jackson-dataformat-xml のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
-
XmlMapper with `FAIL_ON_UNKNOWN_PROPERTIES` fails on whitespace-only element対応中かも @arimu1 が 89 日前に担当しました。 オープンto-evaluate
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
-
3.x
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
FasterXML/jackson-dataformat-xml#787 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
FasterXML/jackson-dataformat-xml#712 · コメント 3 件 ·
FasterXML/jackson-dataformat-xml の issue をすべて見る
似ている issue
-
Cleanup: restore the interrupt flag in AiFailureAnalyzer対応中かも @Rishankgupta08 が今日担当しました。 オープンgood first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
seleniumboot/selenium-boot#258 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
johanhaleby/occurrent#1505 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
FasterXML/jackson-databind#6443 ·
メンテナーはふだん 1 日以内に返信
-
Docs: 2 broken linksオープン
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信