Forum Discussion

John_R__Brewste's avatar
John_R__Brewste
Occasional Contributor
16 years ago

XmlHoder Null Pointer Exception

Greetings

I am running a GroovyScript that has the following code:

...

def holder = groovyUtils.getXmlHolder( it.name+"#Response" );
if (holder["//ns1:FunctionReturnCode"] == "SUCCESS") {
...

The issue is the #Response may or may not be there.  Therefore I am getting a NullPointerException.  This, for one, locks up my system for about 20 minutes while it does something ... However, I want to know how I can check for a valid response without getting a nullPointer?

Is there a check I can run.  I looked at the API for xmlHoder but I cannot find anything.

Thanks,
Jb

1 Reply

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi John,

    hmm.. you have a point :-) I'll add a "hasContent" property to the XmlHolder, until then you could try checking for the response with

    if( context.expand( it.name + "#Response") == null )
      return


    does that help?

    regards,

    /Ole
    eviware.com