From f21c10882e74ec58260cae289c4180c19ff8a816 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Fri, 2 May 2014 18:29:42 +0300 Subject: Fix improper merge of 3d0ff32b from 7.1 to master (#13620) Correctly call PushConnection.disconnect instead of setting to null. Also remove the obsolete PushHandler.disconnectCallback. Change-Id: Ied055d489a269b016318947cd89cf0b46003c596 --- .../vaadin/server/communication/PushHandler.java | 47 +++------------------- 1 file changed, 6 insertions(+), 41 deletions(-) (limited to 'server/src') diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java index c6126f9d21..983ada3279 100644 --- a/server/src/com/vaadin/server/communication/PushHandler.java +++ b/server/src/com/vaadin/server/communication/PushHandler.java @@ -186,46 +186,6 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter { } }; - /** - * Callback used when a connection is closed, either deliberately or because - * an error occurred. - */ - private final PushEventCallback disconnectCallback = new PushEventCallback() { - @Override - public void run(AtmosphereResource resource, UI ui) throws IOException { - PushMode pushMode = ui.getPushConfiguration().getPushMode(); - AtmospherePushConnection connection = getConnectionForUI(ui); - - String id = resource.uuid(); - - if (connection == null) { - getLogger() - .log(Level.WARNING, - "Could not find push connection to close: {0} with transport {1}", - new Object[] { id, resource.transport() }); - } else { - if (!pushMode.isEnabled()) { - /* - * The client is expected to close the connection after push - * mode has been set to disabled. - */ - getLogger().log(Level.FINER, - "Connection closed for resource {0}", id); - } else { - /* - * Unexpected cancel, e.g. if the user closes the browser - * tab. - */ - getLogger() - .log(Level.FINER, - "Connection unexpectedly closed for resource {0} with transport {1}", - new Object[] { id, resource.transport() }); - } - connection.disconnect(); - } - } - }; - private VaadinServletService service; public PushHandler(VaadinServletService service) { @@ -428,7 +388,12 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter { "Connection unexpectedly closed for resource {0} with transport {1}", new Object[] { id, resource.transport() }); } - ui.setPushConnection(null); + if (pushConnection.isConnected()) { + // disconnect() assumes the push connection is connected but + // this method can currently be called more than once during + // disconnect, depending on the situation + pushConnection.disconnect(); + } } } catch (final Exception e) { -- cgit v1.2.3