Updated to getting Groovy size() error

One of my personal apps began throwing size() errors on .size() = 1, after updating to
No time to figure it out now, reverted back to prior firmware and all is OK again.

	if (settings."${settingDevice}".size() == 1)
			{ it2 ->
			if (triggerId == it2.id)
				return true
				return false

Added some debugging before attempting to update. However, it all looks good. What changed?

 log.debug "settings.${settingDevice}"
 log.debug settings."$settingDevice".size()  


Hard to tell without similar logs from the first execution (I know, I know, not possible now), but the most reasonable guess is that settings."${settingDevice}" did not exist so returned null and, in turn, the call to .size() failed. Without logging (again, I know, I know...), I don't suppose it would be possible for you to see what setting it was looking for and what the value, if one existed (which you could see in "App Status") was?

The null-safe ?. instead of . may help here if you think the value might ever be null or an empty list (at least .size() would fail gracefully and an if with that expression would evaluate to false). However, if you're confident that should never happen, then I don't know. :slight_smile:

1 Like

That was also my original thought, however the debugging on 2.2.2 were the same contacts and motions failing in 2.2.3.

Also tried the failsafe? but it continued failing in 2.2.3, so reverted to 2.2.2 where I did the debugging. My gut says there may be an issue with the run time resolution of the tested field name not working in 2.2.3

The app is a parent/child with a total of ~1000 lines of code.

Had a bit of time so reinstalled 2.2.3, added some debuggihg, and it failed.

        log.debug "line 874 settings.${settingDevice}"
        log.debug settings."${settingDevice}".size()

After reviewing the settings I decided to save and rebuild everything and it worked! Not sure what occurred or what fixed it.

Now on 2.2.3

I now have an idea of what went wrong.

To speed up some logic that determines which light(s) need to be turned on when a contact, motion or switch is triggered I build a cross reference kept in a state field. The settings.global1288Contacts shown in the debug in the prior post does not exist and should have been global1761Contacts. It seems that the relative offsets of the light devices changed causing the code to pick up an incorrect device id.

Hopefully I'm done with any additional fallout from 2.2.3

1 Like