[
https://issues.apache.org/jira/browse/VELOCITY-689?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Nathan Bubna resolved VELOCITY-689.
-----------------------------------
Resolution: Fixed
Fix Version/s: 2.0
Ok, fixed in the trunk and merged/adapted to the two other active branches.
Ugh. Two branches was plenty. Let's get 1.6.2 out already, and be done with
that branch.
> ClassMap misses super interfaces
> --------------------------------
>
> Key: VELOCITY-689
> URL: https://issues.apache.org/jira/browse/VELOCITY-689
> Project: Velocity
> Issue Type: Bug
> Affects Versions: 1.5, 1.6, 1.6.1
> Reporter: Nathan Bubna
> Priority: Minor
> Fix For: 1.6.2, 1.7, 2.0
>
>
> Hi devs,
> when we upgrade to velocity1.6.1. But the process failed. we found a
> critical bug in velocity1.6.1 . I have mock the bug in details:
> First step:
> public interface ITestBean2{
> String getName();
> }
> public interface ITestBean extends ITestBean2 {
> }
> private static class TestBean implements ITestBean {
> private String name = "test bean method name";
> public String getName() {
> return name;
> }
> }
> then set up velocity excute template code:
> context.put("testBean", new TestBean());
> System.out.println(evaluate("$testBean.getName()"));
> We found $testBean.getName() can not be rendered.The template can be
> rendered in version1.4. Then I debug several hours(I never read velocity
> code before), we found a bug in class
> org.apache.velocity.util.introspection.ClassMap::createMethodCache() . Code
> "classToReflect.getInterfaces() " is not correct used, Class.getInterfaces()
> Can *ONLY* get parent interfaces, it can not get a super super interface.
> So Code "createMethodCache()" missed a interface check.
> Leon Liu
> ================================================
> private MethodCache createMethodCache()
> {
> MethodCache methodCache = new MethodCache(log);
> for (Class classToReflect = getCachedClass(); classToReflect != null
> ; classToReflect = classToReflect.getSuperclass())
> {
> if (Modifier.isPublic(classToReflect.getModifiers()))
> {
> populateMethodCacheWith(methodCache, classToReflect);
> }
> *Class [] interfaces = classToReflect.getInterfaces();*
> for (int i = 0; i < interfaces.length; i++)
> {
> if (Modifier.isPublic(interfaces[i].getModifiers()))
> {
> populateMethodCacheWith(methodCache, interfaces[i]);
> }
> }
> }
> return methodCache;
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]