It’s been like this for as long as I’ve been using compile static in Groovy. I assumed that was expected behavior and I make sure to point it out to all new developers in our project as one of the Groovy gotchas. Is it not supposed to be that way?
From: Paolo Di Tommaso [mailto:email@example.com]
Sent: Friday, December 15, 2017 2:29 AM
Subject: Re: @CompileStatic null iteration
Just found the same problem. This difference can introduce subtle bugs when refactoring groovy code to CompileStatic.
I suggest to report a bug for that.
On Tue, Dec 12, 2017 at 12:45 AM, MG <firstname.lastname@example.org> wrote:
just a quick question since we came across it today when testing code that had been converted from dynamic to static Groovy: Is the behavior that statically compiled Groovy throws a NPE when the iterable to be iterated over is null (same as Java), while dynamically compiled Groovy uses the NullObject.iterator(), i.e. does not throw but instead iterates over an empty collection by design ?