You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/07/27 16:03:00 UTC

[jira] [Commented] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

    [ https://issues.apache.org/jira/browse/GROOVY-9662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17165812#comment-17165812 ] 

Eric Milles commented on GROOVY-9662:
-------------------------------------

Am I correct in understanding that "call (...) { ...}" is supposed to be resolving "call" against the delegate?  There was a change to give Closure's methods like "getDelegate()", "getResolveStrategy()", etc. a higher priority so that any delegate that implements methodMissing would not trap them.  GROOVY-9604 and https://github.com/apache/groovy/commit/f60285ec072821502f33d7a999b5574bee53b6e2

> Groovy 3.0.5: Closure delegate is not working properly
> ------------------------------------------------------
>
>                 Key: GROOVY-9662
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9662
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5
>            Reporter: Puneet Behl
>            Priority: Major
>
> In Grails Views, we are using closures to generate JSON using `StreamingJsonBuilder`. The HAL implementation for an entity now generates an incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from Grails Views: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
>     call(SELF_ATTRIBUTE) {
>         call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: HttpMethod.GET, absolute: true)
>         call HREFLANG_ATTRIBUTE, locale.toString()
>         call TYPE_ATTRIBUTE, contentType
>     }
>     Set<Link> links = getLinks(object)
>     for (link in links) {
>         call(link.rel) {
>             call HREF_ATTRIBUTE, link.href
>             call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: locale.toString()
>             def linkType = link.contentType
>             if (linkType) {
>                 call TYPE_ATTRIBUTE, linkType
>             }
>         }
>     }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I believe that is not working correctly because it works if I change the above to:
> {code:java}
> delegate.call (...
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)