Scott,
I might be wrong, but it looks like your ICF returns a null toString -- your
result can be repeated e.g., by this code:
===
class Uhoh {
String toString() { null }
}
def icf=new Uhoh()
System.out.println("is icf null? " + (icf == null));
System.out.println("is icf not null? " + (icf != null));
System.out.println("what is icf? " + icf);
===
Trick is, toString() is what "print icf" implicitly does. To know more about
the object, you might try e.g.,
===
println "icf is some ${icf.getClass()}"
System.out.println("icf is some " + icf.getClass()); // about the same in
Javaish
===
All the best,
OC
On 13. 7. 2016, at 17:01, Scott Arnold <[email protected]> wrote:
> I'm new to Groovy (lots of Java experience but almost no Groovy experience)
> and maybe there is something very basic I am missing here, but I am running
> into the following issue in a Grails app (but I think it's a not
> understanding Groovy issue). I'm not sure I can break it down any further
> than I already have, so I am kind of stumped about what I am doing wrong here.
>
> In case you know Grails and want some detail on where this code is happening,
> I'm working on a pre-existing Grails app that calls a service from the
> BootStrap.groovy during application startup. The code I'm having a problem
> with is within the service class.
>
> Here's the code snippet:
>
> System.out.println("is icf null? " + (icf == null));
> System.out.println("is icf not null? " + (icf != null));
> System.out.println("what is icf? " + icf);
>
> And here's the output:
>
> is icf null? false
> is icf not null? true
> what is icf? Null
>
> If I try to call a method on icf, I get a NullPointerException. However,
> earlier in the code icf is created (currently it is created Java-style rather
> than using def, as in ICF icf = new ICF()) and the code tries to set several
> property values within icf (e.g. icf.code = suchandsuch) and none of that
> throws any errors.
>
> What might be happening here?
>
> Thanks.