You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arno Schumacher <ar...@brokat.com> on 2000/07/28 18:13:14 UTC

Another Bug in Digester.java

Hi

  there is another bug in digester

Arno



Digester.java:

    /**
     * Process notification of the end of the document being reached.
     *
     * @exception SAXException if a parsing error is to be reported
     */
    public void endDocument() throws SAXException {

	[..]

        // Perform final cleanup
        clear();

    }



    /**
     * Clear the current contents of the object stack.
     */
    public void clear() {

        match = "";
        while (!bodyTexts.empty())
            bodyTexts.pop();
        while (!stack.empty())
            stack.pop();

	#######
        root = null;
	#######
    }




    /**
     * Parse the content of the specified URI using this Digester.
     * Returns the root element from the object stack (if any).
     *
     * @param uri URI containing the XML data to be parsed
     *
     * @exception IOException if an input/output error occurs
     * @exception SAXException if a parsing exception occurs
     */
    public Object parse(String uri) throws IOException, SAXException {

        getParser().parse(uri, this);

	##############

        return (root);
	
	#############

----> return is always >null<


    }




Re: Another Bug in Digester.java

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
I copied the idea of returning the root element from the stack from the
way that XmlMapper works in Tomcat (used to read the server.xml and
web.xml files).  In practice, I've found that this is not particularly
useful -- I have always found myself ignoring the return value anyway.
Thus, I never tested this feature.  Also, if you use the standard rules,
the stack will always be empty at the end anyway, because every rule that
pushes something on the stack pops it off when it is done.

What would you think about changing the return type of the
Digester.parse() methods to be "void" instead of "Object"?

Craig

PS:  I fixed the bug you reported on CallParamRule -- it was also present
in CallMethodRule.  Thanks for the bug report!




Arno Schumacher wrote:

> Hi
>
>   there is another bug in digester
>
> Arno
>
> Digester.java:
>
>     /**
>      * Process notification of the end of the document being reached.
>      *
>      * @exception SAXException if a parsing error is to be reported
>      */
>     public void endDocument() throws SAXException {
>
>         [..]
>
>         // Perform final cleanup
>         clear();
>
>     }
>
>     /**
>      * Clear the current contents of the object stack.
>      */
>     public void clear() {
>
>         match = "";
>         while (!bodyTexts.empty())
>             bodyTexts.pop();
>         while (!stack.empty())
>             stack.pop();
>
>         #######
>         root = null;
>         #######
>     }
>
>     /**
>      * Parse the content of the specified URI using this Digester.
>      * Returns the root element from the object stack (if any).
>      *
>      * @param uri URI containing the XML data to be parsed
>      *
>      * @exception IOException if an input/output error occurs
>      * @exception SAXException if a parsing exception occurs
>      */
>     public Object parse(String uri) throws IOException, SAXException {
>
>         getParser().parse(uri, this);
>
>         ##############
>
>         return (root);
>
>         #############
>
> ----> return is always >null<
>
>     }