Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: core
-
Labels:None
-
Number of attachments :
Description
Say you are writing to an output stream with namespace prefixes.
writer.startTagNamespaces(2, "stream", new int[]
{ 2, 3 }, new String[]
{ "stream", "" });
When you reset the writer either by calling reset() or setOutput(), the namespace prefixes are not closed. You must close the tag by calling endTag() in order for the namespaces to be closed properly. However, it is not guaranteed that the endTag() will be called for each corresponding startTagNamespaces().
The situation can occur either if the stream is unexpectedly closed or if a setOutput() is explicitly called before writing out the end tag. In such cases, the namespaces must be closed and resetted in order for the writer to be reused. Otherwise, the writer will always think those namespaces have already been defined, thus making the xml writer not recyclable as intended.
On a side note.
closeNamespaces() should also do a sanity check.
If m_namespaceStack.pop() returns a null, then the method should either do nothing or reset the the stack and depth. Currently, if pop() return null, likely, the method will throw a NPE.