groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Wagenleitner (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (GROOVY-6584) Cannot use memoize() to cache metaclass method call
Date Fri, 07 Oct 2016 04:04:21 GMT

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

John Wagenleitner resolved GROOVY-6584.
---------------------------------------
       Resolution: Fixed
         Assignee: John Wagenleitner
    Fix Version/s: 2.4.8

Thanks for reporting the issue.

> 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.4#6332)

Mime
View raw message