FreemarkerConfig sharedVariables doesn't play well with content2bean
--------------------------------------------------------------------

                 Key: MAGNOLIA-3811
                 URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-3811
             Project: Magnolia
          Issue Type: Bug
      Security Level: Public
          Components: core, freemarker
    Affects Versions: 4.4.4
            Reporter: Grégory Joseph
            Assignee: Philipp Bärfuss
             Fix For: 4.4.5


In some cases, {{FreemarkerConfig}}'s {{sharedVariables}} aren't populated 
properly by content2bean. It seems to be due to the order of methods (which can 
be lost/changed when hot deploying classes, for example). 

{{FreemarkerConfig}} has two {{addSharedVariable}} methods, one of which takes 
an {{Object}} value (which is what c2b should use) and one which takes a 
{{Template}} model instance (which could be used in cases where we have a 
pre-wrapped object we want to expose).

This was done as a result of mistakenly thinking c2b would pick the most 
appropriate method, depending on the arguments (i.e like Java does naturally 
with method overloading). However, it's not the case: when looking for "add" 
methods, Content2bean uses the first one it finds with a matching name. In this 
case, and when source code order was preserved, it finds and uses 
({{addSharedVariable(String name, Object value}}) and everything's peachy.

Obviously this highly depends on the order of the methods, i.e depends on how 
the code was compiled. In most cases, it seems the source order is kept, but 
probably when hot deploying classes, this order can change. As a result, c2b 
sometimes uses the {{addSharedVariable(String name, TemplateModel value}} 
method, which results in a reflection exception (arguments mismatch).

This has already been fixed on the trunk for 4.5 with SCRUM-30, so we'll apply 
the same fix on the 4.4 branch, simply removing the {{addSharedVariable(String 
name, TemplateModel value}}, which never worked.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira




----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to