Two wrapped lists with items of same name conflict when XML Annotations and both JaxbAnnotationModule and JakartaXmlBindAnnotationModule are used
まだ誰も着手していません。
評価
調査の方向性
Start by tracing how the XML module combines annotations from JaxbAnnotationModule and JakartaXmlBindAnnotationModule when discovering wrapped list properties. Reproduce the reported failure with the supplied Wrapper record and both modules, then compare it with the Jackson XML annotations case. Done means serialization succeeds for both lists with the same @XmlElement name when both annotation modules are registered.
索引モデルが issue の本文から書いたものです。
説明
This seems a very specific case left after https://github.com/FasterXML/jackson-dataformat-xml/issues/192 was solved.
Using Jackson 3.3.0, this:
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import org.junit.jupiter.api.Test;
import tools.jackson.dataformat.xml.XmlMapper;
import tools.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationModule;
import tools.jackson.module.jaxb.JaxbAnnotationModule;
class NestedListsWithObjectsWithJaxbAndJakartaModules {
record Wrapper(@XmlElementWrapper(name = "ones") @XmlElement(name = "name") List<String> ones,
@XmlElementWrapper(name = "twos") @XmlElement(name = "name") List<String> twos) {
}
@Test
void shouldHandleNestedListsWithObjectsWithJaxbAndJakartaModules() {
Wrapper wrapper = new Wrapper(List.of("item0"), List.of("item1"));
XmlMapper.builder()
.addModules(new JaxbAnnotationModule())
.addModule(new JakartaXmlBindAnnotationModule())
.build()
.writeValueAsString(wrapper);
}
}
fails with:
tools.jackson.databind.exc.InvalidDefinitionException: Invalid type definition for type `test.NestedListsWithObjectsWithJaxbAndJakartaModules$Wrapper`: Conflicting getter definitions for property "name": test.NestedListsWithObjectsWithJaxbAndJakartaModules$Wrapper#ones() vs test.NestedListsWithObjectsWithJaxbAndJakartaModules$Wrapper#twos()
at [No location information]
at tools.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:75)
at tools.jackson.databind.SerializationContext.reportBadTypeDefinition(SerializationContext.java:1366)
at tools.jackson.databind.DatabindContext.reportBadTypeDefinition(DatabindContext.java:712)
at tools.jackson.databind.SerializationContext._createAndCacheUntypedSerializer(SerializationContext.java:1026)
at tools.jackson.databind.SerializationContext.findValueSerializer(SerializationContext.java:829)
at tools.jackson.databind.SerializationContext.findTypedValueSerializer(SerializationContext.java:625)
at tools.jackson.dataformat.xml.ser.XmlSerializationContext.serializeValue(XmlSerializationContext.java:80)
at tools.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:1921)
at tools.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:1857)
at test.NestedListsWithObjectsWithJaxbAndJakartaModules.shouldHandleNestedListsWithObjectsWithJaxbAndJakartaModules(NestedListsWithObjectsWithJaxbAndJakartaModules.java:28)
Suppressed: tools.jackson.core.exc.StreamWriteException: Trying to write END_DOCUMENT when document has no root (ie. trying to output empty document).
at [No location information]
at tools.jackson.dataformat.xml.util.StaxUtil.throwAsWriteException(StaxUtil.java:29)
at tools.jackson.dataformat.xml.ser.ToXmlGenerator._closeInput(ToXmlGenerator.java:1862)
at tools.jackson.core.base.GeneratorBase.close(GeneratorBase.java:335)
at tools.jackson.databind.util.ClassUtil.closeOnFailAndThrowAsJacksonE(ClassUtil.java:413)
at tools.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:1923)
... 2 more
Caused by: com.ctc.wstx.exc.WstxOutputException: Trying to write END_DOCUMENT when document has no root (ie. trying to output empty document).
at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1618)
at com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1653)
at com.ctc.wstx.sw.BaseStreamWriter._finishDocument(BaseStreamWriter.java:1457)
at com.ctc.wstx.sw.BaseStreamWriter.closeCompletely(BaseStreamWriter.java:962)
at tools.jackson.dataformat.xml.ser.ToXmlGenerator._closeInput(ToXmlGenerator.java:1857)
... 5 more
This only happens if both JaxbAnnotationModule and JakartaXmlBindAnnotationModule are used. And only if @XmlElementWrapper and @XmlElement (does not matter if from the javax or jakarta package) are used. It works with @JacksonXmlElementWrapper and @JacksonXmlProperty.
By the way: Thank you very much for providing Jackson!
- 主要言語
- 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日 初心者へのやさしさ 45/100
FasterXML/jackson-dataformat-xml#931 · コメント 3 件 ·
-
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 日以内に返信