stefan-egli commented on a change in pull request #4:
URL:
https://github.com/apache/sling-org-apache-sling-discovery-commons/pull/4#discussion_r708145713
##########
File path:
src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java
##########
@@ -590,6 +595,46 @@ public void run() {
}
}
+ protected boolean equalsIgnoreSyncToken(BaseTopologyView newView) {
+ if (previousView==null) {
+ return false;
+ }
+ if (newView==null) {
+ throw new IllegalArgumentException("newView must not be null");
+ }
+ final ClusterView cluster =
newView.getLocalInstance().getClusterView();
+ if (cluster instanceof LocalClusterView) {
+ final LocalClusterView local = (LocalClusterView)cluster;
+ if (!local.hasPartiallyStartedInstances()) {
+ // then we should not ignore the syncToken I'm afraid
+ return previousView.equals(newView);
+ }
+ }
+ final Set<InstanceDescription> previousInstances =
previousView.getInstances();
+ final Set<InstanceDescription> newInstances = newView.getInstances();
+ if (previousInstances.size() != newInstances.size()) {
+ return false;
+ }
+ for (Iterator<InstanceDescription> it = previousInstances.iterator();
it.hasNext();) {
+ InstanceDescription instanceDescription = (InstanceDescription) it
+ .next();
+ boolean found = false;
+ for (Iterator<?> it2 = newInstances.iterator(); it2
+ .hasNext();) {
+ InstanceDescription otherId = (InstanceDescription) it2
+ .next();
+ if (instanceDescription.equals(otherId)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ return false;
+ }
+ }
+ return true;
Review comment:
indeed, I think that should be possible. I will do that but also add
some test cases to be on the safe side (plus it has no unit test coverage
anyway)
--
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]