Hi I have found a bug in
org.apache.velocity.util.introspection.ClassMap and would like to suggest a fix for it. Please see below and advise if you need more information - feedback appreciated! Thanks a bunch Sven ======================================================================= Nightly build : http://jakarta.apache.org/builds/jakarta-velocity/nightly/2002-03-14/ Type: org.apache.velocity.util.introspection.ClassMap Method: private static String makeMethodKey(String method, Object[] params) Description: This method calculates a key for given method-name and parameters. It's really just a helper but it has a side-effect. It changes the given array's content! The bug manifests itself as described in http://www.mail-archive.com/[email protected]/msg05999.html If you put a null-value in a context's collection or a business- object returns null then makeMethodKey turns the null into ClassMap.OBJECT. This only happens the first time when the key hasn't been computed before. Resolution: Remove the side-effect : =========== diff =============================== D:\sven\changes>diff ClassMap.java ..\original\ClassMap.java 275,282c275,276 < // 20020314 [EMAIL PROTECTED] < // Instead of changing the input params-array with < // params[j] = OBJECT < // we keep the 'null'-check local < Object arg = params[j]; < if (arg == null) { < arg = OBJECT; < } --- > if (params[j] == null) > params[j] = OBJECT; 284c278 < methodKey.append(arg.getClass().getName()); --- > methodKey.append(params[j].getClass().getName()); =========== result =============================== private static String makeMethodKey(String method, Object[] params) { StringBuffer methodKey = new StringBuffer().append(method); for (int j = 0; j < params.length; j++) { // 20020314 [EMAIL PROTECTED] // Instead of changing the input params-array with // params[j] = OBJECT // we keep the 'null'-check local Object arg = params[j]; if (arg == null) { arg = OBJECT; } methodKey.append(arg.getClass().getName()); } return methodKey.toString(); } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
