You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/02/10 21:41:00 UTC
[jira] [Closed] (GROOVY-10731) Exceptions thrown from MarkupTemplateEngine when map accessors and GString interpolation are used
[ https://issues.apache.org/jira/browse/GROOVY-10731?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-10731.
------------------------------
> Exceptions thrown from MarkupTemplateEngine when map accessors and GString interpolation are used
> -------------------------------------------------------------------------------------------------
>
> Key: GROOVY-10731
> URL: https://issues.apache.org/jira/browse/GROOVY-10731
> Project: Groovy
> Issue Type: Bug
> Components: Templating
> Affects Versions: 4.0.0, 4.0.1, 4.0.2, 4.0.4, 4.0.5
> Reporter: Kyle Moore
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.5, 2.5.19, 3.0.13
>
>
> I've observed some breaking behavior beginning with v4.0.0 and continuing through the latest 4.0.5-SNAPSHOT. All examples below pass in v3.0.12.
> This is a simplification of errors seen when using the japicmp-gradle-plugin v3.0.0 inside the Gradle build; specifically its use of this [template|https://github.com/melix/japicmp-gradle-plugin/blob/master/src/main/resources/templates/default.groovy] to create a HTML report.
> There are three different error messages produced, illustrated by the three examples below: [mapLookup, nestedGString, noGString]
> Here is a script to reproduce:
> {code:groovy}
> import groovy.text.markup.MarkupTemplateEngine;
> import groovy.text.markup.TemplateConfiguration;
> def tryTemplate(name, template) {
> TemplateConfiguration templateConfiguration = new TemplateConfiguration();
> templateConfiguration.setAutoNewLine(true); // Removing this fixes nestedGString
> MarkupTemplateEngine engine = new MarkupTemplateEngine(templateConfiguration);
> try {
> println("Trying $name")
> engine.createTemplate(template)
> } catch (Throwable e) {
> println(e.message)
> }
> }
> tryTemplate('mapLookup', '''
> def severityMappings = [:]
> String err = ""
> // 1. these two lines fail
> // produces a java.lang.ArrayIndexOutOfBoundsException: size==0
> def foo = severityMappings[err]
> span(class: "label label-${foo}")
> ''')
> tryTemplate('nestedGString', '''
> def severityMappings = [:]
> String err = ""
> // 2. just the span line fails
> // throws groovy.lang.GroovyRuntimeException: ASM reporting processing error for GeneratedMarkupTemplate121$_run_closure1#doCall with signature java.lang.Object doCall(java.lang.Object) in GeneratedMarkupTemplate121:12. GeneratedMarkupTemplate121
> html {
> span(class: "label label-${severityMappings[err]}")
> }
> ''')
> tryTemplate('noGString', '''
> def severityMappings = [:]
> String err = ""
> // 3. no GString interpolation fails
> // BUG! exception in phase 'class generation' in source unit 'GeneratedMarkupTemplate82' Error while popping argument from operand stack tracker in class
> def foo = "label label-" + severityMappings[err]
> span(class: foo)
> ''')
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)