Skip to content

Removes use of JAXB API via jackson-dataformat-xml#29384

Merged
terrymanu merged 2 commits into
apache:masterfrom
linghengqian:remove-jaxb
Dec 13, 2023
Merged

Removes use of JAXB API via jackson-dataformat-xml#29384
terrymanu merged 2 commits into
apache:masterfrom
linghengqian:remove-jaxb

Conversation

@linghengqian

@linghengqian linghengqian commented Dec 12, 2023

Copy link
Copy Markdown
Member

For #26041.

Changes proposed in this pull request:

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.954 s <<< FAILURE! -- in org.apache.shardingsphere.data.pipeline.core.job.PipelineJobIdUtilsTest
[ERROR] org.apache.shardingsphere.data.pipeline.core.job.PipelineJobIdUtilsTest.assertParse -- Time elapsed: 0.869 s <<< ERROR!
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 optional type `java.util.Optional<java.lang.String>` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jdk8" to enable handling (through reference chain: org.apache.shardingsphere.data.pipeline.scenario.migration.MigrationJobId["jobType"]->org.apache.shardingsphere.data.pipeline.scenario.migration.MigrationJobType["toBeStartDisabledNextJobType"])
        at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
        at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1330)
        at com.fasterxml.jackson.databind.ser.impl.UnsupportedTypeSerializer.serialize(UnsupportedTypeSerializer.java:35)
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:732)
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:183)
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:732)
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:183)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:502)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:341)
        at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4793)
        at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:4038)
        at org.apache.shardingsphere.infra.util.json.JsonUtils.toJsonString(JsonUtils.java:61)
        at org.apache.shardingsphere.data.pipeline.core.job.id.PipelineJobId.marshalSuffix(PipelineJobId.java:54)
        at org.apache.shardingsphere.data.pipeline.core.job.id.PipelineJobIdUtils.marshal(PipelineJobIdUtils.java:52)
        at org.apache.shardingsphere.data.pipeline.core.job.PipelineJobIdUtilsTest.assertParse0(PipelineJobIdUtilsTest.java:44)
        at org.apache.shardingsphere.data.pipeline.core.job.PipelineJobIdUtilsTest.assertParse(PipelineJobIdUtilsTest.java:38)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.

public final class JDBCRepositorySQL {

@XmlAttribute(required = true)
@JacksonXmlProperty(isAttribute = true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We lost required here? Is there no such property with JacksonXmlProperty?

@linghengqian linghengqian Dec 13, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • There is no direct equivalent.

Unfortunately XML is special: due to structure being what it is, empty Element looks either as "Object with no properties" or "empty String".

final XmlMapper xmlMapper = new XmlMapper();

xmlMapper.configure(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES, true);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I'm not sure how the JAXB API handles the required attribute.

  • In my local unit test, jaxb-runtime does not throw an exception for empty elements, but gets null values normally like jackson-dataformat-xml. required seems to be just for IDE censorship.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see. It could be better to open an issue since we need more investigation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@terrymanu terrymanu added this to the 5.4.2 milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.

3 participants