W3CDOMStreamReader returns wrong type in moveToChild()
------------------------------------------------------

                 Key: CXF-1915
                 URL: https://issues.apache.org/jira/browse/CXF-1915
             Project: CXF
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.0.9
         Environment: jdk 1.5 / 1.6
            Reporter: Marc Giger


I hit a special case under the following conditions:

- WSS enabled so that the W3CDOMStreamReader is called.
- A Document where directly after an element a xml-comment follows (int my case 
directly after the root element):
<rootElement><!-- some comment --><nextChildElement>

In this case where no TextNode or something other is between, I got the 
following NPE:

Caused by: java.lang.NullPointerException
        at 
org.apache.cxf.staxutils.W3CDOMStreamReader.getTextCharacters(W3CDOMStreamReader.java:289)
        at 
org.apache.cxf.staxutils.DepthXMLStreamReader.getTextCharacters(DepthXMLStreamReader.java:159)
        at 
com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleCharacters(StAXStreamConnector.java:282)
        at 
com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:146)
        at 
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:332)
        at 
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:311)
        at 
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:578)
        ... 53 more

Attached is a patch which corrects 1) the order and 2) returns correctly the 
comment type if the current content is a comment
node. The order is very imortant as e.g the 
com.sun.xml.messaging.saaj.soap.impl.CommentImpl implements javax.xml.soap.Text 
where javax.xml.soap.Text implements org.w3c.dom.Text and so it must be checked 
before org.w3c.dom.Text

This bug has its root in the xfire stack. An xfire based project from us is 
also affected.
I think the reason why this wasn't detected until now is, that most users use a 
binding framework.  Binding framworks
normally don't marshall comments if nothing special is configured.

Thanks

Marc

-- 
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