Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jackson2ExecutionContextStringSerializer ignores QName prefix #4697

Open
jpraet opened this issue Oct 30, 2024 · 0 comments
Open

Jackson2ExecutionContextStringSerializer ignores QName prefix #4697

jpraet opened this issue Oct 30, 2024 · 0 comments
Labels
status: waiting-for-triage Issues that we did not analyse yet type: bug

Comments

@jpraet
Copy link
Contributor

jpraet commented Oct 30, 2024

Bug description
See FasterXML/jackson-databind#4771: jackson QName (de)serialization ignores prefix.

Environment
Spring Batch 5.1.2, JDK 21

Steps to reproduce

    @Test
    void qname() throws Exception {
        Jackson2ExecutionContextStringSerializer serializer = new Jackson2ExecutionContextStringSerializer();
        ExecutionContext context = new ExecutionContext();
        QName qname = new QName("http://namespace", "test", "p");
        context.put("qname", qname);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        serializer.serialize(new HashMap<>(context.toMap()), outputStream);
        LOGGER.info(outputStream.toString(StandardCharsets.UTF_8));
        // <- {"@class":"java.util.HashMap","qname":["javax.xml.namespace.QName","{http://namespace}test"]}
        Map<String, Object> result = serializer.deserializeFromByteArray(outputStream.toByteArray());
        QName value = (QName) result.get("qname");
        assertThat(value.getLocalPart()).isEqualTo(qname.getLocalPart());
        assertThat(value.getNamespaceURI()).isEqualTo(qname.getNamespaceURI());
        assertThat(value.getPrefix()).isEqualTo(qname.getPrefix()); // <- fails
    }

Expected behavior
QName prefix is preserved in context (de)serialization roundtrip.

Spring Batch StaxEventItemWriter depends on QName prefix being preserved correctly:

if (!unclosedHeaderCallbackElements.isEmpty()) {
executionContext.put(getExecutionContextKey(UNCLOSED_HEADER_CALLBACK_ELEMENTS_NAME),
unclosedHeaderCallbackElements);
}

@jpraet jpraet added status: waiting-for-triage Issues that we did not analyse yet type: bug labels Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage Issues that we did not analyse yet type: bug
Projects
None yet
Development

No branches or pull requests

1 participant