[groovy-user] currying Closure with null as first argument fails

1 view
Skip to first unread message

Dinko Srkoc

unread,
Aug 1, 2011, 9:29:49 AM8/1/11
to us...@groovy.codehaus.org
Hi list,

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


Paul King

unread,
Aug 1, 2011, 4:02:29 PM8/1/11
to us...@groovy.codehaus.org

Yes, please raise a bug. We can always close it if it
turns out that there was an intended change.

Cheers, Paul.

Dinko Srkoc

unread,
Aug 1, 2011, 6:01:23 PM8/1/11
to us...@groovy.codehaus.org
On 1 August 2011 22:02, Paul King <pa...@asert.com.au> wrote:
>
> Yes, please raise a bug. We can always close it if it
> turns out that there was an intended change.
>

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.

Reply all
Reply to author
Forward
0 new messages