From 22f09cfeafcae80a8660ac2dcbb3918597321187 Mon Sep 17 00:00:00 2001 From: Juuso Valli Date: Sat, 13 Sep 2014 15:19:55 +0300 Subject: Improve proxy comparison support (#14639) Change-Id: I114ea5bf9d55c78826c1163206caf585b96143ef --- .../com/vaadin/server/AbstractClientConnector.java | 31 +++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'server/src') diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java index d8d0d5cbd9..1f13010638 100644 --- a/server/src/com/vaadin/server/AbstractClientConnector.java +++ b/server/src/com/vaadin/server/AbstractClientConnector.java @@ -1001,11 +1001,6 @@ public abstract class AbstractClientConnector implements ClientConnector, this.errorHandler = errorHandler; } - private AbstractClientConnector getInstance() { - // returns the underlying instance regardless of proxies - return this; - } - /* * (non-Javadoc) * @@ -1013,12 +1008,36 @@ public abstract class AbstractClientConnector implements ClientConnector, */ @Override public boolean equals(Object obj) { + if (this == obj) { + return true; + } + /* + * This equals method must return true when we're comparing an object to + * its proxy. This happens a lot with CDI (and possibly Spring) when + * we're injecting Components. See #14639 + */ if (obj instanceof AbstractClientConnector) { - return super.equals(((AbstractClientConnector) obj).getInstance()); + AbstractClientConnector connector = (AbstractClientConnector) obj; + return connector.isThis(this); } return false; } + /** + * For internal use only, may be changed or removed in future versions. + *

+ * This method must be protected, because otherwise it will not be redefined + * by the proxy to actually be called on the underlying instance. + *

+ * See #14639 + * + * @deprecated only defined for framework hacks, do not use. + */ + @Deprecated + protected boolean isThis(Object that) { + return this == that; + } + /* * (non-Javadoc) * -- cgit v1.2.3