jsedding commented on code in PR #33:
URL:
https://github.com/apache/sling-org-apache-sling-jcr-repoinit/pull/33#discussion_r928719636
##########
src/main/java/org/apache/sling/jcr/repoinit/impl/NodePropertiesVisitor.java:
##########
@@ -308,6 +317,17 @@ private void setNodeProperties(String nodePath,
List<PropertyLine> propertyLines
}
}
+ private boolean equalValues(Value[] a1, Value[] a2) throws
ValueFormatException, IllegalStateException, RepositoryException {
+ boolean result = true;
+ Iterator<Value> it1 = Arrays.stream(a1).iterator();
+ Iterator<Value> it2 = Arrays.stream(a2).iterator();
+ // each item needs to have same value in same order
+ while(it1.hasNext() && it2.hasNext())
+ result = result &&
it1.next().getString().equals(it2.next().getString());
Review Comment:
This loop never exits once `result == false` because `it1.next()` (and
`it2.next()`) is never called.
Furthermore, I would compare the value's type (just in case, because the
property type comparison should already have caught this.
Note: at first I thought `Arrays.equals(a1, a2)` would do the trick. But it
turns out that different `Value` implementations are compared and they
implement `#equals()` in a way that only values using the same implementation
are equal.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]