groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-6584) Cannot use memoize() to cache metaclass method call
Date Sun, 02 Oct 2016 20:02:20 GMT

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

ASF GitHub Bot commented on GROOVY-6584:
----------------------------------------

GitHub user jwagenleitner opened a pull request:

    https://github.com/apache/groovy/pull/434

    GROOVY-6584: Cannot use memoize() to cache metaclass method call

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jwagenleitner/groovy GROOVY-6584

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/434.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #434
    
----
commit 7d651b5c5bc119fdf687dd49eb78dbe7c146a5db
Author: John Wagenleitner <jwagenleitner@apache.org>
Date:   2016-10-02T19:23:16Z

    GROOVY-6584: Cannot use memoize() to cache metaclass method call

----


> 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
>
> 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