Author: wglass Date: Sun Jan 29 18:34:47 2006 New Revision: 373415 URL: http://svn.apache.org/viewcvs?rev=373415&view=rev Log: prevent potential NPE when evaluating references
Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java jakarta/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java URL: http://svn.apache.org/viewcvs/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java?rev=373415&r1=373414&r2=373415&view=diff ============================================================================== --- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java (original) +++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java Sun Jan 29 18:34:47 2006 @@ -96,8 +96,6 @@ try { - Class c = o.getClass(); - /* * first, see if we have this information cached. */ @@ -111,7 +109,7 @@ * that is fixed in the template :) */ - if (icd != null && icd.contextData == c) + if ( icd != null && (o != null) && (icd.contextData == o.getClass()) ) { vg = (VelPropertyGet) icd.thingy; } @@ -124,10 +122,10 @@ vg = rsvc.getUberspect().getPropertyGet(o,identifier, uberInfo); - if (vg != null && vg.isCacheable()) + if (vg != null && vg.isCacheable() && (o != null)) { icd = new IntrospectionCacheData(); - icd.contextData = c; + icd.contextData = o.getClass(); icd.thingy = vg; context.icachePut(this,icd); } Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java URL: http://svn.apache.org/viewcvs/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java?rev=373415&r1=373414&r2=373415&view=diff ============================================================================== --- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java (original) +++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java Sun Jan 29 18:34:47 2006 @@ -155,7 +155,7 @@ method = rsvc.getUberspect().getMethod(o, methodName, params, new Info(context.getCurrentTemplateName(), getLine(), getColumn())); - if (method != null) + if ((method != null) && (o != null)) { icd = new IntrospectionCacheData(); icd.contextData = o.getClass(); Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java URL: http://svn.apache.org/viewcvs/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java?rev=373415&r1=373414&r2=373415&view=diff ============================================================================== --- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java (original) +++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java Sun Jan 29 18:34:47 2006 @@ -150,6 +150,9 @@ public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) throws Exception { + if (obj == null) + return null; + AbstractExecutor executor; Class claz = obj.getClass(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]