commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Kudła <>
Subject [digester] ofTypeSpecifiedByAttribute doesnt work
Date Thu, 02 Feb 2012 03:12:53 GMT

tonight I have spent 5 hours working over one bug in my app.

Unfortunately I digged to some place of code where I think I found a
bug in Digester

It is in: org.apache.commons.digester3.ObjectCreateRule

I think this part of code:
    public void begin( String namespace, String name, Attributes attributes )
        throws Exception
        Class<?> clazz = this.clazz;

        if ( clazz == null )
            // Identify the name of the class to instantiate
            String realClassName = className;
            if ( attributeName != null )
                String value = attributes.getValue( attributeName );
                if ( value != null )
                    realClassName = value;
            if ( getDigester().getLogger().isDebugEnabled() )
                getDigester().getLogger().debug( format(
"[ObjectCreateRule]{%s} New '%s'",

                                                         realClassName ) );

            // Instantiate the new object and push it on the context stack
            clazz = getDigester().getClassLoader().loadClass( realClassName );

doesn't work in that way I want.

When I have specified this rule:

and having this XML:
<activationFunction type="org.kobrys.LinearActivationFunction" a="1" b="0"/>

and of course LinearActivationFunction is a subclass of

When is used method ofType(...) - it is set this.clazz which
automaticaly distable acces in the 'if' part of code body.

This code works but allways returns DefaultActivationFunction. Inside
ObjectCreateRule instance attributeName is not null so it looks like
if statement is some kind of wrong.

Am I doing something wrong? Or is it a bug?

Adam Kudła

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message