Skip to content

Templates from plugins are cached too eagerly #10339

@pereiss

Description

@pereiss

Task List

  • Steps to reproduce provided
  • Example that reproduces the problem attached
  • Full description of the issue provided (see below)

This may be somewhat related to #10047:
Having two plugins that provide the same template (same name, same path). First called template is cached and it's not possible anymore to access the template from the second plugin.

<g:render template="theTemplate" plugin="pluginA" />
<g:render template="theTemplate" plugin="pluginB" />

Expected Behaviour

Content of pluginA's template followed by content of pluginB's template

Actual Behaviour

Twice pluginA's content.

I was able to track this down to org.grails.web.gsp.GroovyPagesTemplateRenderer, method

private Template findAndCacheTemplate(Object, TemplateVariableBinding, String, String, String, final String)

    scriptSource = groovyPageLocator.findTemplateInBinding(controller, pluginName, templatePath, pageScope);
   ...
    if (scriptSource == null) {
        cacheKey = contextPath + pluginName + uri;
    } else {
        cacheKey = scriptSource.getURI();
    }

Actually, scriptSource is not null (since fix for #10047?) and going into the else-branch (omitting pluginName) is wrong.

Steps to Reproduce/Example Application

  1. git clone https://github.com/pereiss/templatebug.git
  2. cd templatebug/myapp
  3. grails run-app
  4. call http://localhost:8080

Environment Information

  • Operating System: Ubuntu Linux 16.04
  • Grails Version: 3.1.11+, 3.2+
  • JDK Version: jdk8

templatebug.zip

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions