STRICT_DUPLICATE_DETECTION rejects repeated XML elements read by a custom deserializer
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Java
- Star
- 636
- Fork
- 250
- Merge trung bình
- 7 giờ 10 phút
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của FasterXML/jackson-dataformat-xml
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
-
XmlMapper with `FAIL_ON_UNKNOWN_PROPERTIES` fails on whitespace-only elementCó thể đã có người làm @arimu1 đã nhận 89 ngày trước. Đang mởto-evaluate
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
-
3.x
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
FasterXML/jackson-dataformat-xml#787 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
FasterXML/jackson-dataformat-xml#712 · 3 bình luận ·
Tất cả issue của FasterXML/jackson-dataformat-xml
Issue tương tự
-
Cleanup: restore the interrupt flag in AiFailureAnalyzerCó thể đã có người làm @Rishankgupta08 đã nhận hôm nay. Đang mởgood first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
seleniumboot/selenium-boot#258 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
dense-analysis/ale#5181 ·
-
bug subsystem:agent-harness triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ShaftHQ/SHAFT_ENGINE#8043 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
johanhaleby/occurrent#1505 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày