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

XMLEventStreamWriter fails to handle writeEmptyElement() followed by writeAttribute() [SPR-11254] #15879

spring-projects-issues opened this issue Dec 22, 2013 · 1 comment
in: core status: backported type: bug


Copy link

@spring-projects-issues spring-projects-issues commented Dec 22, 2013

Archie Cobbs opened SPR-11254 and commented

XMLEventStreamWriter converts an XMLStreamWriter into an XMLEventWriter.

However, it fails to handle the following sequence of API calls:


What happens is you get this exception:

Caused by: Attribute not associated with any element
        at org.springframework.util.xml.XMLEventStreamWriter.writeAttribute(

The problem is that the XMLEventStreamWriter implementation seems to think that "writeEmptyElement" means "write element with no attributes", whereas what it really means is "write element with no nested content" (i.e., an element that can be self-closing).

The usage above is explicitly supported by the XMLStreamWriter API and in the JDK implementation results in a self-closing tag being emitted -- with or without attributes.

The fix is to keep track of whether the most recent element is self-closing or not.

Affects: 3.2.6, 4.0 GA


Backported to: 3.2.7

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 22, 2013

Archie Cobbs commented

Attaching a patch that fixes the problem for me.

@spring-projects-issues spring-projects-issues added type: bug status: backported in: core labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.0.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core status: backported type: bug
None yet

No branches or pull requests

2 participants