diff options
author | Henri Sara <hesara@vaadin.com> | 2012-11-27 14:56:22 +0000 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-11-27 14:56:22 +0000 |
commit | d7fa318bfd22f4274bec57d09bb74d98e458fc1a (patch) | |
tree | 6eda3f85568d4adde504bd26ac48c78f76708f82 | |
parent | a58a1e23b882bbe59dc966b87fc69834d4304162 (diff) | |
parent | 38053e8f2bd993389b3c3fce5861b6db37e66e01 (diff) | |
download | vaadin-framework-d7fa318bfd22f4274bec57d09bb74d98e458fc1a.tar.gz vaadin-framework-d7fa318bfd22f4274bec57d09bb74d98e458fc1a.zip |
Merge "Fixed ClassCastException and returning of wrong connector (#10399)"
-rw-r--r-- | client/src/com/vaadin/client/ConnectorMap.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/ConnectorMap.java b/client/src/com/vaadin/client/ConnectorMap.java index 0c6698bfd5..b3da12e6a3 100644 --- a/client/src/com/vaadin/client/ConnectorMap.java +++ b/client/src/com/vaadin/client/ConnectorMap.java @@ -50,7 +50,7 @@ public class ConnectorMap { } /** - * Returns a {@link ComponentConnector} element by its root element + * Returns a {@link ComponentConnector} element by its root element. * * @param element * Root element of the {@link ComponentConnector} @@ -58,7 +58,23 @@ public class ConnectorMap { * registered */ public ComponentConnector getConnector(Element element) { - return (ComponentConnector) getConnector(getConnectorId(element)); + ServerConnector connector = getConnector(getConnectorId(element)); + if (!(connector instanceof ComponentConnector)) { + // This can happen at least if element is not part of this + // application but is part of another application and the connector + // id happens to map to e.g. an extension in this application + return null; + } + + // Ensure this connector is really connected to the element. We cannot + // be sure of this otherwise as the id comes from the DOM and could be + // part of another application. + ComponentConnector cc = (ComponentConnector) connector; + if (cc.getWidget() == null || cc.getWidget().getElement() != element) { + return null; + } + + return cc; } /** |