【发布时间】:2012-09-25 23:28:41
【问题描述】:
我有一些例程在 grails 2.1.0/groovy 1.8.6 中工作,但在 grails 2.1.1/groovy 1.8.8 中停止工作。
此代码在 grails 2.1.0 中运行:
def items = []
Object[] item = ["Fluff", new Date(), 11235813]
items << item
println items
assert !items.findAll{it[0] == "Pelusa"}
assert items.findAll{it[0] == "Fluff"}
当我在 grails 2.1.1 中运行它时,它会抛出这个异常:
groovy.lang.MissingMethodException: No signature of method:
Script1$_run_closure1.doCall() is applicable for argument types:
(java.lang.String, java.util.Date, java.lang.Integer) values:
[Fluff, Wed Sep 26 01:02:23 ??? 2012, 11235813]
Possible solutions: doCall(), call(), doCall(java.lang.Object), findAll()
这是一些环境信息:
java version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2a-0ubuntu0.12.04.1)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
我怎样才能让它再次工作?
编辑:我认为这可能是 Grails 问题,因为它在 Groovy Console 2.0.1 上运行良好
编辑:这可能是一个错误。 I raised a jira issue.
【问题讨论】:
-
发布代码的相关部分。没有它,我们不知道“项目”是什么。
-
在 Groovy 1.8.6 和 1.8.8 中尝试过该代码,它在这两个版本中都可以工作......
-
我明白你的意思...它通过 DefaultGroovyMethods 中的 this line 并反过来触发 BooleanClosureWrapper 中的调用方法。这一定与 Groovy 在
items.findAll { a, b, c -> a == 'Fluff' }工作时展开列表有关。不知道为什么它在 Groovy 中有效,但在 Grails 中无效 :-( -
感谢@tim_yates,我正在更改我的代码以在闭包中使用显式变量。这可能是一个错误,这是解决方法。
-
仅供参考:这个问题的深层原因是 Groovy 中的一个错误,应该用 2.0.5(和 1.8.9)修复:jira.codehaus.org/browse/GROOVY-5730