Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Delaigue2015-05-18 12:10:16 +0000
committerLaurent Delaigue2015-05-18 12:10:16 +0000
commit858cf201d263ecdf997da3a468e4456e579bab63 (patch)
tree6082a48e634c785beb15a4d9a042c9a727dbad64
parentfa7980b6cf4c58aa39cf3cb5a6f6fb9da89f2051 (diff)
downloadorg.eclipse.emf.compare-858cf201d263ecdf997da3a468e4456e579bab63.tar.gz
org.eclipse.emf.compare-858cf201d263ecdf997da3a468e4456e579bab63.tar.xz
org.eclipse.emf.compare-858cf201d263ecdf997da3a468e4456e579bab63.zip
[462938] Prevent infinite loop during merge.
Local and remote URIs are different so the test used to stop resolving remote resource was broken. Local URIs start with "platform:/resource" whereas remote URIs for new resources don't. Bug: 462938 Change-Id: I8262187c0898a5c4b5c3aa663ad9ebde1035b845 Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/resolver/ModelsResolution.java66
1 files changed, 32 insertions, 34 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/resolver/ModelsResolution.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/resolver/ModelsResolution.java
index b2cc9cc23..499007a23 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/resolver/ModelsResolution.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/resolver/ModelsResolution.java
@@ -290,42 +290,46 @@ public class ModelsResolution extends AbstractResolution {
final Set<URI> additionalURIs = new LinkedHashSet<URI>();
// Have we found new resources in the right as compared to the left?
Set<IStorage> differenceRightLeft = additional;
- while (!differenceRightLeft.isEmpty()) {
+ boolean somethingToAdd = !differenceRightLeft.isEmpty();
+ while (somethingToAdd) {
+ somethingToAdd = false;
// There's at least one resource in the right that was not found in the left.
- /*
- * This might be a new resource added on the right side... but it might also be a cross-reference
- * that's been either removed from left or added in right. In this second case, we need the
- * resource to be present in both traversals to make sure we'll be able to properly detect
- * potential conflicts. However, since this resource could itself be a part of a larger logical
- * model, we need to start the resolving again with it.
- */
+ // This might be a new resource added on the right side... but it might also be a cross-reference
+ // that's been either removed from left or added in right. In this second case, we need the
+ // resource to be present in both traversals to make sure we'll be able to properly detect
+ // potential conflicts. However, since this resource could itself be a part of a larger logical
+ // model, we need to start the resolving again with it.
final Set<IStorage> additionalLeft = findAdditionalRemoteTraversal(leftSet, differenceRightLeft,
DiffSide.SOURCE, tspm);
- leftSet.addAll(additionalLeft);
- for (IStorage storage : additionalLeft) {
- final URI newURI = asURI().apply(storage);
- if (additionalURIs.add(newURI)) {
- additionalStorages.add(storage);
+ if (leftSet.addAll(additionalLeft)) {
+ somethingToAdd = true;
+ for (IStorage storage : additionalLeft) {
+ final URI newURI = asURI().apply(storage);
+ if (additionalURIs.add(newURI)) {
+ additionalStorages.add(storage);
+ }
}
}
- /*
- * have we only loaded the resources that were present in the right but not in the left, or have
- * we found even more?
- */
+ // have we only loaded the resources that were present in the right but not in the left, or have
+ // we found even more?
final Set<IStorage> differenceAdditionalLeftRight = difference(additionalLeft, asURISet(rightSet));
// If so, we once more need to augment the right traversal
final Set<IStorage> additionalRight = findAdditionalRemoteTraversal(rightSet,
differenceAdditionalLeftRight, DiffSide.REMOTE, tspm);
- rightSet.addAll(additionalRight);
- for (IStorage storage : additionalRight) {
- final URI newURI = asURI().apply(storage);
- if (additionalURIs.add(newURI)) {
- additionalStorages.add(storage);
+ if (rightSet.addAll(additionalRight)) {
+ somethingToAdd = true;
+ for (IStorage storage : additionalRight) {
+ final URI newURI = asURI().apply(storage);
+ if (additionalURIs.add(newURI)) {
+ additionalStorages.add(storage);
+ }
}
}
// Start this loop anew if we once again augmented the right further than what we had in
// left
- differenceRightLeft = difference(additionalRight, asURISet(leftSet));
+ if (somethingToAdd) {
+ differenceRightLeft = difference(additionalRight, asURISet(leftSet));
+ }
}
return additionalStorages;
}
@@ -355,21 +359,15 @@ public class ModelsResolution extends AbstractResolution {
private void loadAdditionalRemoteStorages(Set<IStorage> leftSet, Set<IStorage> rightSet,
Set<IStorage> originSet, Set<IStorage> additional, ThreadSafeProgressMonitor tspm)
throws InterruptedException {
- /*
- * This loop will be extremely costly at best, but we hope the case to be sufficiently rare (and the
- * new resources well spread when it happens) not to pose an issue in the most frequent cases.
- */
-
+ // This loop will be extremely costly at best, but we hope the case to be sufficiently rare (and the
+ // new resources well spread when it happens) not to pose an issue in the most frequent cases.
Set<IStorage> additionalStorages = additional;
while (!additionalStorages.isEmpty()) {
- // There's at least one resource that is in the origin set yet neither in left nor in
- // right.
+ // There's at least one resource that is in the origin set yet neither in left nor in right.
final Set<IStorage> additionalLeftRightComparedToOrigin = loadAdditionalRemoteStorages(leftSet,
rightSet, additionalStorages, tspm);
- /*
- * Have we found even more resources to add to the traversal? If so, augment the origin
- * accordingly.
- */
+ // Have we found even more resources to add to the traversal? If so, augment the origin
+ // accordingly.
final Set<IStorage> additionalOrigin = findAdditionalRemoteTraversal(originSet,
additionalLeftRightComparedToOrigin, DiffSide.ORIGIN, tspm);
originSet.addAll(additionalOrigin);

Back to the top