Skip to content

OAK-12213 Tree store: child node list maybe be incorrect if an intermediate node is missing#2902

Open
thomasmueller wants to merge 4 commits into
trunkfrom
OAK-12213
Open

OAK-12213 Tree store: child node list maybe be incorrect if an intermediate node is missing#2902
thomasmueller wants to merge 4 commits into
trunkfrom
OAK-12213

Conversation

@thomasmueller
Copy link
Copy Markdown
Member

No description provided.

@sonarqubecloud
Copy link
Copy Markdown

throw new IllegalArgumentException(key);
}
current = key.substring(index + 1);
if (!key.startsWith(path + "\t")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly this is a stop condition because we've reached the sibling following the current node ? So treeStore.getSession().iterator(path) returns all the paths starting a path depth first ? So the method should really be named getDescendantNodeNamesIterator(String path), or do I miss understand something ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly this is a stop condition because we've reached the sibling following the current node ?

Yes. The bug is that a node was returned that is not a child node.

So treeStore.getSession().iterator(path) returns all the paths starting a path depth first ?

It doesn't use depth-first; it returns the entries in key order. I have now updated the documentation.

So the method should really be named getDescendantNodeNamesIterator(String path)

The methods is supposed to return only the direct children. But it returned non-children in some specific cases. This PR is supposed to fix that, so it only returns direct children.

Comment on lines 188 to 189
Iterator<Entry<String, String>> it = treeStore.getSession().iterator(path);
return new Iterator<String>() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To follow the sonar point, this could indeed moved to an explicit TreeStorePathIterator class. that you could just instanciate here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, this could be done, but I don't think it would make the code easier to understand. I think whether or not a separate class should be used here is an issue that is unrelated to his PR.

Cognitive Complexity

For this case, I don't agree with Sonar that this method is too complex and should be split into multiple methods.

assertEquals("/test", e.getPath());
e = it.next();
assertEquals("/test-node", e.getPath());
Iterator<String> it2 = e.getNodeState().getChildNodeNames().iterator();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With these 2 iterators this test is hard to follow. Would there be any way to make it clearer to the reader ? I am missing the intent of the test, to be able to validate that the test is correctly checking that intent (which I am sure it is, knowing the author ;) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants