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 2017/02/01 23:19:01 UTC

[jira] [Closed] (GROOVY-6584) Cannot use memoize() to cache metaclass method call

     [ https://issues.apache.org/jira/browse/GROOVY-6584?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-6584.
-----------------------------

> Cannot use memoize() to cache metaclass method call
> ---------------------------------------------------
>
>                 Key: GROOVY-6584
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6584
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.2.1
>            Reporter: Sargis Harutyunyan
>            Assignee: John Wagenleitner
>             Fix For: 2.4.8
>
>
> Hi I want to extend my list with new method and cache the result because actually it will query db but I am getting 'java.lang.UnsupportedOperationException', I reproduced it for simple case also using groovy console
> {code}
> def lst = []
> lst.metaClass.getTotalCount = {
>     println ">>>>>>>>>> 12 <<<<<<<<<<"
>     12 // can be some select count(*) from xxx
> }.memoize()
> println lst.getTotalCount()
> println lst.getTotalCount()
> {code}
> I am getting
> {noformat}
> java.lang.UnsupportedOperationException: org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod$AnonymousMetaMethod
> 	at ConsoleScript10.run(ConsoleScript10:2)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)