Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.8.1
-
Fix Version/s: 1.8.2, 1.9-beta-3, 1.7.11
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
Widget.groovy
class Widget {
}
testscript.groovy
Widget.metaClass.invokeMethod = { String methodName, Object[] args ->
args.each { a ->
println a.class
}
}
w = new Widget()
w.doSometing([] as Object[])
With Groovy 1.8.0:
pojoproblem $ groovy -version Groovy Version: 1.8.0 JVM: 1.6.0_26 pojoproblem $ groovy testscript.groovy class [Ljava.lang.Object;
With Groovy 1.8.1:
pojoproblem $ groovy -version Groovy Version: 1.8.1 JVM: 1.6.0_26 pojoproblem $ groovy testscript.groovy Caught: java.lang.NullPointerException java.lang.NullPointerException at testscript$_run_closure1_closure2.doCall(testscript.groovy:4) at testscript$_run_closure1.doCall(testscript.groovy:3) at testscript.run(testscript.groovy:10)
I think (not 100% sure) the NPE is related to the delegate property in PojoWrapper being null. PojoWrapper.getProperty(String) is called, which looks like this:
public Object getProperty(final String property) {
return this.delegate.getProperty(this.wrapped, property);
}
Is the wrapper really supposed to be passed into the closure or is it supposed to be the unwrapped object?