summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2013-06-05 16:20:27 +0300
committerVaadin Code Review <review@vaadin.com>2013-06-06 16:20:06 +0000
commit8eb567eb3e0650fcbaa7296e6ff4e42e8000e4ce (patch)
tree5fe29982bab70caaf8b8217397510b1d325ba9fe /server/src/com/vaadin/ui
parent8f4add90a7b6c851d26114b946a5a36470004b2f (diff)
downloadvaadin-framework-8eb567eb3e0650fcbaa7296e6ff4e42e8000e4ce.tar.gz
vaadin-framework-8eb567eb3e0650fcbaa7296e6ff4e42e8000e4ce.zip
Make UI.pushConnection transient to prevent null resource after deserialization (#11809)
* PushConnection is not Serializable anymore * AtmospherePushConnection fields are not transient * UI.setSession calls setPushConnection(null) instead of pushConnection.disconnect() * pushConnection.disconnect() asserts isConnected() * If UI has a push connection, it should now always have isConnected() == true Change-Id: I3c2e877b8e723b7cc2993cacd620920aecdef5fb
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r--server/src/com/vaadin/ui/UI.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index fa38666dc2..6c9551ea81 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -411,12 +411,9 @@ public abstract class UI extends AbstractSingleComponentContainer implements
} else {
if (session == null) {
detach();
- if (pushConnection != null && pushConnection.isConnected()) {
- // Close the push connection when UI is detached. Otherwise
- // the push connection and possibly VaadinSession will live
- // on.
- pushConnection.disconnect();
- }
+ // Close the push connection when UI is detached. Otherwise the
+ // push connection and possibly VaadinSession will live on.
+ setPushConnection(null);
}
this.session = session;
}
@@ -536,7 +533,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
private Navigator navigator;
- private PushConnection pushConnection = null;
+ private transient PushConnection pushConnection = null;
private boolean hasPendingPush = false;
@@ -1072,7 +1069,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
boolean sessionExpired = (session == null || session.isClosing());
getRpcProxy(UIClientRpc.class).uiClosed(sessionExpired);
- if (getPushConnection() != null && getPushConnection().isConnected()) {
+ if (getPushConnection() != null) {
// Push the Rpc to the client. The connection will be closed when
// the UI is detached and cleaned up.
getPushConnection().push();
@@ -1342,19 +1339,24 @@ public abstract class UI extends AbstractSingleComponentContainer implements
/**
* Returns the internal push connection object used by this UI. This method
- * should only be called by the framework.
+ * should only be called by the framework. If the returned PushConnection is
+ * not null, it is guaranteed to have {@code isConnected() == true}.
*/
public PushConnection getPushConnection() {
+ assert (pushConnection == null || pushConnection.isConnected());
return pushConnection;
}
/**
* Sets the internal push connection object used by this UI. This method
- * should only be called by the framework.
+ * should only be called by the framework. If {@pushConnection} is not null,
+ * its {@code isConnected()} must be true.
*/
public void setPushConnection(PushConnection pushConnection) {
// If pushMode is disabled then there should never be a pushConnection
- assert (getPushConfiguration().getPushMode().isEnabled() || pushConnection == null);
+ assert (pushConnection == null || getPushConfiguration().getPushMode()
+ .isEnabled());
+ assert (pushConnection == null || pushConnection.isConnected());
if (pushConnection == this.pushConnection) {
return;