Forum Discussion

larsn's avatar
larsn
Contributor
11 years ago

[Resolved] groovy step requires escaping question mark

I have a function that generates the following exception:

Thu Apr 03 11:52:31 EDT 2014:ERROR:java.lang.NullPointerException: Cannot execute null+null
java.lang.NullPointerException: Cannot execute null+null
at org.codehaus.groovy.runtime.NullObject.plus(NullObject.java:121)
at org.codehaus.groovy.runtime.NullObject$plus.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at CommonAssertions$_luhnChecksum_closure5.doCall(Script3.groovy:233)

line 233 is:
total += (index % 2 ==0) ? digit : [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][digit]

When I escape the question mark, the groovy code runs without errors:
total += (index % 2 ==0) \? digit : [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][digit]

Using SoapUI Pro 4.6.4 Build Date: 20140113-1235

3 Replies

  • OK, this bug is squirrely. I've changed my project some more and now I'm getting an exception because the slash is in front of the question mark. I remove the slash - escape char and the Groovy lib runs again.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    This does not look like it is related to SoapUI, but looks to be related to Groovy. This is not a bug in SoapUI funtionality, you should post Groovy related issues in the Groovy bug system http://jira.codehaus.org/browse/GROOVY.




    Regards,
    Marcus
    SmartBear Support
  • FYI, I figured out my error. I wasn't initializing "total" with a value so the addition part of "+=" was failing.