velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nbu...@gmail.com>
Subject Re: A bug in class ClassMap
Date Thu, 05 Feb 2009 21:04:47 GMT
Leon, i just went ahead and fixed it myself.  Thanks for offering to
do the patch for it, though.  This is now fixed in the trunk and all
active branches.

On Thu, Feb 5, 2009 at 8:22 AM, Nathan Bubna <nbubna@gmail.com> wrote:
> That's alright.  I opened one for you:
>
> https://issues.apache.org/jira/browse/VELOCITY-689
>
> A quick patch would be great.  We already have a version 1.6.2 almost
> released, but help up over a different issue.  Because of that, we may
> be able to get a fix for this into 1.6.2 as well.  The sooner we have
> a patch for it, the more likely that will be, i think.
>
> On Thu, Feb 5, 2009 at 7:52 AM, Leon sdh5724 <sdh5724@gmail.com> wrote:
>> Hi Bubna,
>>   Sorry my poor english expresion, So jira is diffcult for me to express my
>> idea. Tomorrow I will post a patch code to the maillist. Because It is a
>> very critical bug for me.Would  Dev Team  patch the bug to version 1.6.1
>> soon?
>>
>> Leon
>>
>>
>>
>> 2009/2/5 Nathan Bubna <nbubna@gmail.com>
>>
>>> Thanks for the detailed analysis.  Would you open an issue for this in
>>> our JIRA issue tracker?
>>>
>>> https://issues.apache.org/jira/browse/VELOCITY
>>>
>>> On Thu, Feb 5, 2009 at 7:32 AM, Leon sdh5724 <sdh5724@gmail.com> wrote:
>>> >  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;
>>> >    }
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: dev-help@velocity.apache.org
>>>
>>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Mime
View raw message