Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 14504 invoked from network); 14 Apr 2003 21:33:26 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 14 Apr 2003 21:33:26 -0000 Received: (qmail 22259 invoked by uid 97); 14 Apr 2003 21:35:26 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 22251 invoked from network); 14 Apr 2003 21:35:25 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 14 Apr 2003 21:35:25 -0000 Received: (qmail 14255 invoked by uid 500); 14 Apr 2003 21:33:24 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 14237 invoked from network); 14 Apr 2003 21:33:24 -0000 Received: from pcow034o.blueyonder.co.uk (HELO blueyonder.co.uk) (195.188.53.122) by daedalus.apache.org with SMTP; 14 Apr 2003 21:33:24 -0000 Received: from localhost ([80.194.24.21]) by blueyonder.co.uk with Microsoft SMTPSVC(5.5.1877.757.75); Mon, 14 Apr 2003 22:33:21 +0100 Date: Mon, 14 Apr 2003 22:34:09 +0100 Subject: Re: [Digester] problem calling methods with a primitive parameter but no xml attribute specified Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v482) From: robert burrell donkin To: "Jakarta Commons Developers List" Content-Transfer-Encoding: 7bit In-Reply-To: <3E9A7305.2010800@gameoefter.org> Message-Id: X-Mailer: Apple Mail (2.482) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N thanks Joel, i've been able to construct a test case and a (i think) a fix. could you please test your code against CVS HEAD or wait until the next nightly build and then post back the results to the list? we take backwards compatibility seriously and if this problem has been fixed i intend to push for a new digester release. TIA - robert On Monday, April 14, 2003, at 09:36 AM, Joel Gautschi wrote: > hi robert, > > I wrote three classes and an xml file to demonstrate the problem. > > digester 1.4.1 throws a java.lang.NullPointerException > digester 1.3 returns: stringValue: 'test string' booleanValue: 'false' > > if I add the xml attribute booleanValue with a value to in > test.xml (like ) > digester 1.4.1 and 1.3 work both. > > hope the classes help. > thanks for your time! > joel > > robert burrell donkin wrote: >> digester 1.4.1 should be backwards compatible with digester 1.3 so i'd >> say that this sounds like a bug. i'm having trouble replicating the >> problem exactly and i haven't been able to write a unit test for this >> case. >> could you give me more details about when the problem occurs including >> the rules that you are using and details about the parameters that the >> method takes. ideally, if you could create a simple test case that >> exhibits this problem with generic classes which you would be willing to >> donate the the apache software foundation, then so much the better. >> - robert >> On Friday, April 11, 2003, at 10:24 AM, xPosting 02 wrote: >>> hi, >>> I've got a problem as I wanted to update digester 1.3 to 1.4.1 in one >>> of our >>> projects. >>> >>> I call a method with a primitive (boolean) parameter in a parse rule. >>> if I >>> don't specify an attribute for this parameter in XML, digster 1.3 >>> converted >>> the null value to false (boolean). digester 1.4.1 doesn't converts the >>> null >>> value to false (boolean) but tries to call the method with the null >>> value. >>> because the method expects a >>> primitive boolean value java.lang.reflect.Method.invoke(Native Method) >>> throws >>> a NullPointerException. >>> >>> I think this different behavior between 1.3 and 1.4.1 is because of a >>> difference in CallMethodRule.end() >>> >>> >>> --- digester 1.4.1 --- >>> // Construct the parameter values array we will need >>> // We only do the conversion if the param value is a String and >>> // the specified paramType is not String. >>> Object paramValues[] = new Object[paramTypes.length]; >>> for (int i = 0; i < paramTypes.length; i++) { >>> if(parameters[i] instanceof String && >>> !String.class.isAssignableFrom(paramTypes[i])) { >>> >>> paramValues[i] = >>> ConvertUtils.convert((String) parameters[i], paramTypes[ >>> i] >>> ); >>> } else { >>> paramValues[i] = parameters[i]; >>> } >>> } >>> --- --- >>> >>> --- digester 1.3 --- >>> // Construct the parameter values array we will need >>> Object paramValues[] = new Object[paramTypes.length]; >>> for (int i = 0; i < paramTypes.length; i++) { >>> paramValues[i] = >>> ConvertUtils.convert(parameters[i], paramTypes[i]); >>> } >>> --- --- >>> >>> is this behavior in 1.4.1 a bug or is it 'by design'. >>> if 'by design' is there another solution than writing a method which >>> expects >>> a java.lang.Boolean parameter? >>> >>> joel >>> >>> >>> -------------------------------------------- >>> MySign AG, Switzerland >>> Web: http://www.mysign.ch >>> -------------------------------------------- >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org >>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org >> For additional commands, e-mail: commons-dev-help@jakarta.apache.org > > package test; > > public class TestUtils > { > public void printTestValues( String stringValue, boolean booleanValue > ) > { > System.out.println( "stringValue: '" + stringValue + > "' booleanValue: '" + booleanValue + "'" ); > } > }package test; > > import org.apache.commons.digester.Digester; > import org.apache.commons.digester.RuleSetBase; > > public class TestParseRules extends RuleSetBase > { > public void addRuleInstances(Digester digester) > { > digester.addCallMethod( "document", > "printTestValues", 2, new Class[] { String.class, > boolean.class } ); > digester.addCallParam( "document", > 0, "stringValue" ); > digester.addCallParam( "document", > 1, "booleanValue" ); > } > }package test; > > import java.io.File; > > import org.apache.commons.digester.Digester; > > public class Test > { > public static void main(String[] args) > { > Digester digester = new Digester(); > digester.addRuleSet( new TestParseRules() ); > digester.push ( new TestUtils() ); > try > { > digester.parse( new File ( "test.xml" ) ); > } > catch ( org.xml.sax.SAXException e ) > { > e.printStackTrace(); > } > catch ( java.io.IOException e ) > { > e.printStackTrace(); > } > } > } > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-dev-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org