Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
2.4.0-rc-1, 2.4.0-rc-2
-
None
-
None
-
None
Description
Attached is nullparam.zip which includes the following test:
src/test/groovy/demo/NullParamSpec.groovy
package demo class NullParamSpec extends spock.lang.Specification { void 'test null param'() { setup: String.metaClass.static.methodMissing = { String methodName, Object args -> String.metaClass.static."$methodName" = { Object[] a -> if(a == null) { throw new IllegalArgumentException('Null argument not allowed') } 2112 } 42 } expect: String.doSomething(null) == 42 String.doSomething(null) == 2112 } }
That test fails with 2.4.0-rc-2.
$ ./gradlew test :compileJava UP-TO-DATE :compileGroovy UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :compileTestJava UP-TO-DATE :compileTestGroovy UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test demo.NullParamSpec > test null param FAILED java.lang.IllegalArgumentException at NullParamSpec.groovy:10 1 test completed, 1 failed :test FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':test'. > There were failing tests. See the report at: file:///Users/jeff/nullparam/build/reports/tests/index.html * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 3.913 secs
If you edit build.gradle and change the Groovy version to 2.3.9, 2.3.8, 2.3.7 or 2.3.6 (those are the only versions I tested) the test passes.
I expect the argument "a" to be an array that has 1 element in it and that element is null but instead "a" is null. Is this an intentional change in behavior introduced in 2.4.0?
Attachments
Attachments
Issue Links
- is related to
-
GROOVY-6989 .each{..} Closure With Parameter Typed As Object[] Makes Arguments Object[Object[]]
- Closed