[563242] Ensure Validation works for really ill-formed models/tooling
diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/Diagnostician.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/Diagnostician.java
index 6d07adf..7c6b081 100644
--- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/Diagnostician.java
+++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/Diagnostician.java
@@ -277,7 +277,7 @@
    */
   protected boolean handleThrowable(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, Throwable throwable)
   {
-    if (diagnostics != null && throwable instanceof RuntimeException || throwable instanceof AssertionError)
+    if (diagnostics != null && (throwable instanceof RuntimeException || throwable instanceof AssertionError))
     {
       Object[] messageSubstitutions = new Object []{ EObjectValidator.getObjectLabel(eObject, context) };
       String message = EcorePlugin.INSTANCE.getString("_UI_ValidationFailed_diagnostic", messageSubstitutions);
diff --git a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/ecore/DiagnosticianTest.java b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/ecore/DiagnosticianTest.java
index f6fdcb8..ae2bfe3 100644
--- a/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/ecore/DiagnosticianTest.java
+++ b/tests/org.eclipse.emf.test.core/src/org/eclipse/emf/test/core/ecore/DiagnosticianTest.java
@@ -278,7 +278,7 @@
   }
 
   @Test
-  public void testExceptionHandlingRecorded()
+  public void testExceptionHandlingRecordedNPE()
   {
     final NullPointerException exception = new NullPointerException();
     EClass eClass = new EClassImpl()
@@ -299,7 +299,28 @@
   }
 
   @Test
-  public void testExceptionHandlingNotRecorded()
+  public void testExceptionHandlingRecordedAE()
+  {
+    final AssertionError exception = new AssertionError();
+    EClass eClass = new EClassImpl()
+      {
+        @Override
+        public EList<EClass> getEAllSuperTypes()
+        {
+          throw exception;
+        }
+      };
+
+    Diagnostic diagnostic = Diagnostician.INSTANCE.validate(eClass);
+    Assert.assertEquals("Expected an error", Diagnostic.ERROR, diagnostic.getSeverity());
+    Assert.assertEquals("Expected one child", 1, diagnostic.getChildren().size());
+    Diagnostic child = diagnostic.getChildren().get(0);
+    Throwable diagnosticException = child.getException();
+    Assert.assertSame("Expected the specific exception to be thrown", exception, diagnosticException);
+  }
+
+  @Test
+  public void testExceptionHandlingNotRecordedNPE()
   {
     final NullPointerException exception = new NullPointerException();
     EClass eClass = new EClassImpl()
@@ -322,6 +343,31 @@
       Assert.assertSame("Expected the specific exception to be thrown", exception, throwable);
     }
   }
+  
+  @Test
+  public void testExceptionHandlingNotRecordedAE()
+  {
+    final AssertionError exception = new AssertionError();
+    EClass eClass = new EClassImpl()
+      {
+        @Override
+        public EList<EClass> getEAllSuperTypes()
+        {
+          throw exception;
+        }
+      };
+
+    try
+    {
+      @SuppressWarnings("unused")
+      boolean isValid = Diagnostician.INSTANCE.validate(eClass, (DiagnosticChain)null);
+      Assert.fail("Exected an exception to be thrown");
+    }
+    catch (Throwable throwable)
+    {
+      Assert.assertSame("Expected the specific exception to be thrown", exception, throwable);
+    }
+  }
 
   @Test
   public void testExceptionHandlingNotHandledException()