thenirajpandey / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

InvokeDynamic causes safe-dereference operator to fail on null parameters #326

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have reproduced the problem with this Gist: 
https://gist.github.com/davidnortonjr/6283439

When building Spock tests with the indy flag, null values in the Where block 
parameters break the safe de-reference operator. For example,

        //inputString is null
        String valueAsString = input
        boolean isNumber = valueAsString?.isNumber() // <-- this throws a NullPointerException when input is null, even though we're using the safe-dereference operator!

The stranger thing is that the order of the test runs makes a difference - see 
my Gist for an example. If the test run with a null parameter is first, the 
test passes - however if it runs after a test run with a non-null parameter, 
the test fails.

Using Spock 0.7. Reproducible on both Groovy-indy 2.1.6 and 2.2.0-beta-1

This is reproducible with Gradle 1.7, but it also is reproducible when building 
with IntelliJ (as long as I set up IntelliJ to compile with the indy flag).

Thanks! I am not quite sure why it's happening but the fact that the order of 
the test runs makes a difference causes me to think it is a Spock problem 
rather than a Groovy problem.

Original issue reported on code.google.com by da...@nortoncrew.com on 20 Aug 2013 at 4:23

GoogleCodeExporter commented 8 years ago
It is also reproducible with Groovy 2.1.0

Original comment by da...@nortoncrew.com on 20 Aug 2013 at 4:48