groovy 1.7.10:
8<-------------------------------
assert { x, y -> x ?: y }.curry(1)(3) == 1
assert { x, y -> x ?: y }.curry([null] as Object[])(3) == [null]
assert { x, y -> x ?: y }.curry(null)(3) == 3
------------------------------->8
groovy 1.8.1:
8<-------------------------------
assert { x, y -> x ?: y }.curry(1)(3) == 1
assert { x, y -> x ?: y }.curry([null] as Object[])(3) == 3
{ x, y -> x ?: y }.curry(null)
java.lang.NullPointerException
at org.codehaus.groovy.runtime.CurriedClosure.<init>(CurriedClosure.java:54)
at org.codehaus.groovy.runtime.CurriedClosure.<init>(CurriedClosure.java:86)
at groovy.lang.Closure.curry(Closure.java:527)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:883)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
[...]
------------------------------->8
I suppose this is a bug. Should I raise a JIRA issue?
diff between 1.7.10 and 1.8.1 of CurriedClosure.java yields:
49c49
< public CurriedClosure(int index, Closure uncurriedClosure,
Object[] arguments) {
---
> public CurriedClosure(int index, Closure<V> uncurriedClosure, Object... arguments) {
Cheers,
Dinko
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Cheers, Paul.
The bug is filed here:
http://jira.codehaus.org/browse/GROOVY-4954
I would say that NPE is not quite the expected outcome even if the
change was intended.