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

JAXB.unmarshal of string fails with data generated by JAXB.marshal #1800

Open
joerg1985 opened this issue Mar 25, 2024 · 0 comments
Open

JAXB.unmarshal of string fails with data generated by JAXB.marshal #1800

joerg1985 opened this issue Mar 25, 2024 · 0 comments

Comments

@joerg1985
Copy link

Some special chars will generate XML data that can not be read afterwards.
I would expect the JAXB.marshal call to fail if this is a expected behaviour, rather than generating unparsable data.

ByteArrayOutputStream out = new ByteArrayOutputStream();        
JAXB.marshal("\u0002", out);
JAXB.unmarshal(new ByteArrayInputStream(out.toByteArray()), String.class);

Stacktrace:

javax.xml.stream.XMLStreamException: ParseError at [row,col]:[751712,65]
Message: Ungültiges XML-Zeichen (Unicode: 0x2) wurde im Elementcontent des Dokuments gefunden.
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:652)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamFilterImpl.findNextEvent(XMLStreamFilterImpl.java:152)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamFilterImpl.next(XMLStreamFilterImpl.java:102)
	at org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:165)
	at org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:376)
	... 9 more

Version info:

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>4.0.4</version>
        </dependency>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant