Skip to content

Commit d6b5132

Browse files
committed
OAK-11607 fix test failures
1 parent 0beeeb4 commit d6b5132

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/impl/OrderedChildnameIterable.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ public OrderedChildnameIterator (Iterable<String> orderedChildren, Iterable<Stri
6565
nextResult = getNextElement();
6666
}
6767

68-
String getNextElement() {
69-
String elem = null;
70-
68+
private String getNextElement() {
7169
if (orderedChildren.hasNext()) {
72-
elem = getNextOrderedChild();
70+
String elem = getNextOrderedChild();
7371
if (elem != null) {
7472
return elem;
7573
}
@@ -83,7 +81,7 @@ String getNextElement() {
8381
if (nonOrderedChildrenIterator.hasNext()) {
8482
return nonOrderedChildrenIterator.next();
8583
}
86-
// return all children which have not been consumed from the allChildren iterator yet
84+
// return all children which have not been consumed from the allChildren iterator
8785
if (allChildren.hasNext()) {
8886
return allChildren.next();
8987
}
@@ -92,8 +90,8 @@ String getNextElement() {
9290
}
9391

9492
/**
95-
* Consume the next element from the orderedChild list
96-
* @return null if no ordered child can be retrieved, otherwise the next ordered child name
93+
* Consume the next element from the orderedChild list and validates that it's actually present
94+
* @return the next ordered child or {code null} if all ordered children have already been returned
9795
*/
9896
String getNextOrderedChild() {
9997
String current = null;
@@ -102,6 +100,8 @@ String getNextOrderedChild() {
102100
current = orderedChildren.next();
103101
if (isOrderedChildPresent(current)) {
104102
return current;
103+
} else {
104+
current = null; // skip this element, as it's not present in the allChildren iterator
105105
}
106106
}
107107
return null;

oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/impl/OrderedChildnameIterableTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void orderedChildren() {
9191
@Test
9292
public void orderedChildrenWithNonExistingOrderedChild() {
9393
// the ordered list contains a non-existing childname, which is not part of children list
94-
OrderedChildnameIterable iterable = new OrderedChildnameIterable(List.of("4","5","nonexisting"),ALL_CHILDREN);
94+
OrderedChildnameIterable iterable = new OrderedChildnameIterable(List.of("4","nonexisting1","5","nonexisting2"),ALL_CHILDREN);
9595
Assert.assertEquals(List.of("4","5","1","2","3"), iterableToList(iterable));
9696
}
9797

0 commit comments

Comments
 (0)