You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by robert burrell donkin <ro...@mac.com> on 2002/06/05 23:26:24 UTC

[Digester] Re: NullPointerException when performing addCallMethod

i've just committed a fix for this. if you have access to cvs, then maybe 
you could give the latest version a try.

- robert

On Wednesday, June 5, 2002, at 07:01 PM, Álvaro Barge wrote:

> Hi
>
> I am trying to parse an XML document that has a numeric attribute (size) 
> in one of its elements. I was trying to invoke a setNumber(int value) 
> method in the bean by adding a CallMethodRule and a CallParamRule:
>
> digester.addCallMethod("result/stats",
>                     "setNumber", 1, new String[] {"java.lang.Integer"});
> digester.addCallParam("result/stats", 0, "size");
>
>
> This code throws a NullPointerException in the CallMethodRule(String 
> methodName,int paramCount, String paramTypes[]) constructor (in line 229)
> . (I am using digester 1.2 over Linux with the Sun Java 1.3.1).I have 
> been looking for the error cause, and I have found that the constructor 
> uses a "digester.getClassLoader().load..." method when the paramTypes 
> array specified is not empty.
>
> Well, looking at the digester source code, it seems that the 
> CallMethodRule is created in the addCallMethod method, so in that 
> constructor the digester object has not been set (the setDigester method 
> is invoked in the addRule method of the Digester class, after creating 
> the CallMethodRule). So, IMHO, the NullPointerException will appear 
> whenever a non-empty paramTypes array is specified in the CallMethodRule 
> creation, because the Digester object will never be set in that point of 
> the program. Do you think that this is correct?
>
> I have been also looking at the RuleTestCase, and there are no tests 
> checking this constructor with a non-empty paramTypes array, so this 
> situation is not tested.
>
> In my opinion, the ClassLoader must be obtained using another object and 
> a new test line should be added in the TestCase.
>
> What do you think about this? Is this correct? Has anybody had this 
> problem before?
>
> Thanks,
>
> Álvaro Barge
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.
> org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>