Should BaseStreamWriter / writeCharacters should deal with null text

81 views
Skip to first unread message

benjamin....@gmail.com

unread,
Jul 5, 2016, 9:55:02 AM7/5/16
to Woodstox User Mailing List
Hello,

After discussion on github (https://github.com/FasterXML/woodstox/issues/18) I come here to expose the issue I met.
In the implementation of the XMLStreamWriter (JSR280) : BaseStreamWriter
(https://github.com/FasterXML/woodstox/blob/master/src/main/java/com/ctc/wstx/sw/BaseStreamWriter.java)
the method writeCharacters(String text) does not check for the text to be null (line 464 : int len = text.length();) and we can get a NullPointerException.
In sun implementation (http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java#XMLStreamWriterImpl.writeXMLContent%28java.lang.String%29) a check is done. This defensive approach leads them to write an empty String.
As stated in the github forum, there does not seem to have much usage information in javadocs or specs...

Somehow should the null String be managed?

Thanks

Tatu Saloranta

unread,
Apr 12, 2017, 11:07:44 AM4/12/17
to Woodstox User Mailing List, benjamin....@gmail.com
Just for sake of completeness, this became:


-+ Tatu +-
Reply all
Reply to author
Forward
0 new messages