> Hello all
>
> I'm getting a NullPointerException on this call:
>
> structure.getParent(token, currentNode);
>
> This only occurs when currentNode is the root node, ie "/". (and therefore
> it doesnt have a parent).
>
> I traced it to this line of code. getParentUri is returning null, and
> toString is causing the NullPointerException.
>
> String parentUri = namespace.getUri(objectUri)
> .getParentUri().toString();
>
> It would be nice if either Uri.getParentUri or Structure.getParent could
> throw a NodeHasNoParentException or something similar if it is dealing
with
> the root node.
I feel like returning null in such a case.
When using that call in a loop, it's easier to deal with.
ObjectNode node = retrieveSomeNode();
do {
// do something
node = structure.getParent(token, node);
} while (node != null);
Remy