spring-projects / spring-projects/spring-batch
Jackson2ExecutionContextStringSerializer ignores QName prefix
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 2.5k
- Avg merge
- 6d 53m
- Merged PRs (30d)
- 3
Description
Bug description
See https://github.com/FasterXML/jackson-databind/issues/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:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Jackson2ExecutionContextStringSerializer and run the QName round-trip reproduction from the issue. Trace how QName values are serialized and deserialized, then add or update a regression test so the namespace URI, local part, and prefix are all preserved; done means the shown prefix assertion passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100