diff options
author | Artur Signell <artur@vaadin.com> | 2013-04-26 11:53:59 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-04-26 11:53:59 +0300 |
commit | 947c62d82793da6407c33565c92f2289423f2500 (patch) | |
tree | a366e446492b93245a2c7b086f3e386018e8e866 /server | |
parent | 4738e1f5a46c92b0670edd0b634530c4e66d442c (diff) | |
download | vaadin-framework-947c62d82793da6407c33565c92f2289423f2500.tar.gz vaadin-framework-947c62d82793da6407c33565c92f2289423f2500.zip |
Wait max 1000ms before closing push channel (#11596)
Change-Id: I85c8b0a1f499294b85f130eeb9061644aa8f2f4f
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/communication/AtmospherePushConnection.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java index 770b0b6a59..f33a10c572 100644 --- a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java +++ b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java @@ -21,6 +21,10 @@ import java.io.Serializable; import java.io.StringWriter; import java.io.Writer; import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.logging.Level; +import java.util.logging.Logger; import org.atmosphere.cpr.AtmosphereResource; import org.json.JSONException; @@ -125,12 +129,18 @@ public class AtmospherePushConnection implements Serializable, PushConnection { @Override public void disconnect() { if (lastMessage != null) { + // Wait for the last message to be sent before closing the + // connection (assumes that futures are completed in order) try { - // Wait for the last message to be sent before closing the - // connection (assumes that futures are completed in order) - lastMessage.get(); + lastMessage.get(1000, TimeUnit.MILLISECONDS); + } catch (TimeoutException e) { + getLogger() + .log(Level.INFO, + "Timeout waiting for messages to be sent to client before disconnect"); } catch (Exception e) { - e.printStackTrace(); + getLogger() + .log(Level.INFO, + "Error waiting for messages to be sent to client before disconnect"); } lastMessage = null; } @@ -140,4 +150,12 @@ public class AtmospherePushConnection implements Serializable, PushConnection { .contains(resource); resource = null; } + + /** + * @since + * @return + */ + private static Logger getLogger() { + return Logger.getLogger(AtmospherePushConnection.class.getName()); + } } |