[542789] Avoiding infinite loop in the case of ownership cycle.
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
index 3981c61..3dd952a 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
@@ -9,7 +9,7 @@
  *   IBM - initial API and implementation
  *   Kenn Hussey (Embarcadero Technologies) - 199624, 184249, 204406, 208125, 204200, 213218, 213903, 220669, 208016, 226396, 271470
  *   Nicolas Rouquette (JPL) - 260120, 313837
- *   Kenn Hussey - 286329, 313601, 314971, 344907, 236184, 335125, 528925, 529564, 535301
+ *   Kenn Hussey - 286329, 313601, 314971, 344907, 236184, 335125, 528925, 529564, 535301, 542789
  *   Kenn Hussey (CEA) - 327039, 358792, 364419, 366350, 307343, 382637, 273949, 389542, 389495, 316165, 392833, 399544, 322715, 163556, 212765, 397324, 204658, 408612, 411731, 269598, 422000, 416833, 424568, 427167, 418466, 419324, 429994, 433157, 439915, 446388, 454864, 458906, 461374, 463066, 468230, 481712, 491587, 495564, 512439, 512520, 514386, 514624, 517384
  *   Yann Tanguy (CEA) - 350402
  *   Christian W. Damus (CEA) - 392833, 251963, 405061, 409396, 176998, 180744, 403374, 416833, 420338, 405065, 431342
@@ -12550,14 +12550,20 @@
 		for (Element owner = element; !eClass.isInstance(owningElement)
 			&& owner != null;) {
 
-			owningElement = (Element) owner.eGet(
-				UMLPackage.Literals.ELEMENT__OWNER, resolve);
+			owningElement = (Element) owner
+				.eGet(UMLPackage.Literals.ELEMENT__OWNER, resolve);
 
 			owner = owningElement == null
 				? getNearestBaseElement(resolve
 					? owner.eContainer()
 					: ((InternalEObject) owner).eInternalContainer(), resolve)
 				: owningElement;
+
+			if (owner == element) {
+				throw new IllegalStateException(
+					"There is a cycle in the ownership hierarchy of " //$NON-NLS-1$
+						+ element);
+			}
 		}
 
 		return owningElement;