Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5
-
Fix Version/s: 1.8.6, 2.0-beta-3
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
When I apply the spread operator to a List containing a single null and use the result of that as an argument to .curry, an NPE is thrown with 1.8.x but not with 1.7.10.
script1.groovy
c = { x ->
println "X is ${x}"
}
args = [42]
c = c.curry(*args)
c()
script2.groovy
c = { x, y ->
println "X is ${x}"
println "Y is ${y}"
}
args = [42, 2112]
c = c.curry(*args)
c()
script3.groovy
c = { x, y ->
println "X is ${x}"
println "Y is ${y}"
}
args = [null, null]
c = c.curry(*args)
c()
(This next script is the problematic one...)
script4.groovy
c = { x ->
println "X is ${x}"
}
args = [null]
c = c.curry(*args)
c()
With Groovy 1.7.10:
curry $ groovy -version Groovy Version: 1.7.10 JVM: 1.6.0_29 curry $ curry $ groovy script1 X is 42 curry $ curry $ groovy script2 X is 42 Y is 2112 curry $ curry $ groovy script3 X is null Y is null curry $ curry $ groovy script4 X is null curry $
With Groovy 1.8.5:
curry $ groovy -version Groovy Version: 1.8.5 JVM: 1.6.0_29 Vendor: Apple Inc. OS: Mac OS X curry $ groovy script1 X is 42 curry $ groovy script2 X is 42 Y is 2112 curry $ groovy script3 X is null Y is null curry $ groovy script4 Caught: java.lang.NullPointerException java.lang.NullPointerException at script4.run(script4.groovy:7)
A slightly more simple script which demonstrates what I think is the same problem:
c = { x -> println "X is ${x}" } c = c.curry(null) c()With Groovy 1.7.10:
With Groovy 1.8.5: