Some of the serialize/serializeAndConsume methods are declared on the wrong 
interface
-------------------------------------------------------------------------------------

                 Key: WSCOMMONS-480
                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-480
             Project: WS-Commons
          Issue Type: Bug
          Components: AXIOM
    Affects Versions: Axiom 1.2.8
            Reporter: Andreas Veithen
            Priority: Minor


OMNode declares a set of serialize and serializeAndConsume methods taking an 
OutputStream or a Writer as argument. This is conceptually wrong because these 
methods only make sense for OMElements, not for other OMNodes.

Note that any attempt to call these methods on anything else than an OMElement 
will fail. Consider for example the following code:

        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMText text = factory.createOMText("This is a test");
        text.serialize(System.out);

It will fail with the following exception:

Exception in thread "main" javax.xml.stream.XMLStreamException: Trying to write 
END_DOCUMENT when document has no root (ie. trying to output empty document).
        at 
com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1473)
        at 
com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1502)
        at 
com.ctc.wstx.sw.BaseStreamWriter.finishDocument(BaseStreamWriter.java:1663)
        at com.ctc.wstx.sw.BaseStreamWriter.close(BaseStreamWriter.java:288)
        at 
org.apache.axiom.om.impl.llom.OMNodeImpl.serialize(OMNodeImpl.java:333)
        at Test.main(Test.java:14)

The serialize and serializeAndConsume methods declared by OMNode should be 
moved to the right interface, which would be either OMElement or OMContainer. 
The latter choice would be justified by the fact that all these methods make 
sense for OMDocument as well and some of them are already declared in 
OMDocument.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to