Author: cbrisson
Date: Sun Mar 3 11:31:43 2019
New Revision: 1854695
URL: http://svn.apache.org/viewvc?rev=1854695&view=rev
Log:
[engine] Invalid method calls should definitely be logged
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java?rev=1854695&r1=1854694&r2=1854695&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
Sun Mar 3 11:31:43 2019
@@ -165,6 +165,20 @@ public class ASTMethod extends SimpleNod
VelMethod method = ClassUtils.getMethod(methodName, params,
paramClasses,
o, context, this, strictRef);
+ // warn if method wasn't found (if strictRef is true, then ClassUtils
did thorw an exception)
+ if (o != null && method == null)
+ {
+ StringBuilder plist = new StringBuilder();
+ for (int i = 0; i < params.length; i++)
+ {
+ Class param = paramClasses[i];
+ plist.append(param == null ? "null" : param.getName());
+ if (i < params.length - 1)
+ plist.append(", ");
+ }
+ log.warn("Object '{}' does not contain method {}({}) at {}[line
{}, column {}]", o.getClass().getName(), methodName, plist, getTemplateName(),
getLine(), getColumn());
+ }
+
/*
* The parent class (typically ASTReference) uses the icache entry
* under 'this' key to distinguish a valid null result from a
non-existent method.