NPE in org.apache.xml.serializer.ToHTMLSAXHandler
-------------------------------------------------

         Key: XALANJ-2023
         URL: http://nagoya.apache.org/jira/browse/XALANJ-2023
     Project: XalanJ2
        Type: Bug
  Components: Serialization  
    Versions: 2.6    
    Reporter: Ken Weiner
 Attachments: ToHTMLSAXHandler-patch.txt

On line 360 of org.apache.xml.serializer.ToHTMLSAXHandler, the code does not 
check to see if a lexical handler has been set before trying to call a method 
on it.  The result is the following stack strace when comments are present in 
the XML:

Caused by: java.lang.NullPointerException
        at 
org.apache.xml.serializer.ToHTMLSAXHandler.comment(ToHTMLSAXHandler.java:360)
        at org.apache.xpath.objects.XString.dispatchAsComment(XString.java:287)
        at 
org.apache.xml.dtm.ref.DTMTreeWalker.startNode(DTMTreeWalker.java:233)
        at 
org.apache.xalan.transformer.TreeWalker2Result.startNode(TreeWalker2Result.java:144)
        at org.apache.xml.dtm.ref.DTMTreeWalker.traverse(DTMTreeWalker.java:114)
        at 
org.apache.xalan.transformer.TreeWalker2Result.traverse(TreeWalker2Result.java:72)
        at org.apache.xalan.templates.ElemCopyOf.execute(ElemCopyOf.java:185)
        at 
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
        at 
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177)
        at 
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336)
        ... 21 more

The fix is to add the guard against a null lexical handler:

        if (m_lexHandler != null)
            m_lexHandler.comment(arg0, arg1, arg2);

This guard has been added in the similar comment() method of the 
ToXMLSAXHandler class in the same package.

Possible workaround: Create a dummy LexicalHandler implementation and set that 
on the XMLReader before attempting the transformation.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to