Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2016-10-14 15:19:20 -0400
committerStefan Xenos2016-10-19 01:02:16 -0400
commita9a0971f6f6df5756cd5f315a9d2ea20b1427b74 (patch)
tree0048030dd81f348e1a2059044c4df25baeb51c51
parente7d0599bdc029cb7c6d86ac95ec8dfa906e55c12 (diff)
downloadrt.equinox.bundles-a9a0971f6f6df5756cd5f315a9d2ea20b1427b74.tar.gz
rt.equinox.bundles-a9a0971f6f6df5756cd5f315a9d2ea20b1427b74.tar.xz
rt.equinox.bundles-a9a0971f6f6df5756cd5f315a9d2ea20b1427b74.zip
Bug 505996: Improved diagnostics of adapter contract violations.
Change-Id: Ifbd741f86014edf44968a3db27fc5afc3f8d8dd9 Signed-off-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Adapters.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Adapters.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Adapters.java
index 2035a9fa..e3f78c8d 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Adapters.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Adapters.java
@@ -59,7 +59,10 @@ public class Adapters {
Object result = adaptable.getAdapter(adapter);
if (result != null) {
// Sanity-check
- Assert.isTrue(adapter.isInstance(result));
+ if (!adapter.isInstance(result)) {
+ throw new AssertionFailedException(adaptable.getClass().getName() + ".getAdapter(" + adapter.getName() + ".class) returned " //$NON-NLS-1$//$NON-NLS-2$
+ + result.getClass().getName() + " that is not an instance the requested type"); //$NON-NLS-1$
+ }
return (T) result;
}
}
@@ -74,7 +77,11 @@ public class Adapters {
Object result = queryAdapterManager(sourceObject, adapterId, allowActivation);
if (result != null) {
// Sanity-check
- Assert.isTrue(adapter.isInstance(result));
+ if (!adapter.isInstance(result)) {
+ throw new AssertionFailedException("An adapter factory for " //$NON-NLS-1$
+ + sourceObject.getClass().getName() + " returned " + result.getClass().getName() //$NON-NLS-1$
+ + " that is not an instance of " + adapter.getName()); //$NON-NLS-1$
+ }
return (T) result;
}

Back to the top