Open mathieucarbou opened 7 years ago
In some case, yes it would make sense that we have for example something like: ContextManager.getNodeFor(contextObject) throw NoSuchElementException
. In the case where you would want to make sure that the context object is in the tree.
But in my case, where I just want to query the tree to find some stats, I do not care if the object is there or not, I care about if I have results or not. In my case, I will have some tests elsewhere to verify that some context objects are well put in the tree and that I can have some stat descriptors associated to them. So if I send the wrong context object, and it is not in the tree, this "bug" would be catched at another place (I won't get stats or descriptors).
It's like we would need something like these perhaps ?
ContextManager.getNodeFor(contextObject) throw NoSuchElementException
.build().execute(contextObject);
// would do .build().execute(asList(ContextManager.nodeFor(contextObject)));
.build().execute(asList(ContextManager.getNodeFor(contextObject)));
.build().execute(asList(ContextManager.nodeFor(contextObject)));
// would tolerate nulls to not "search" childs of null root nodes
This issue has been extracted from https://github.com/Terracotta-OSS/statistics/pull/27. See https://github.com/Terracotta-OSS/statistics/pull/27 for the full details
Would it be possible also to add a fix so that we do not have a NPE in the case the object of the query is not in the tree ?
I..e:
Instead of doing:
We should be able to just do something like:
or:
And the query system would just return an empty set of nodes because the queried objects are not there.
(related to https://github.com/Terracotta-OSS/terracotta-platform/pull/263)