summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-08-04 14:12:59 +0300
committerVaadin Code Review <review@vaadin.com>2014-08-07 08:33:10 +0000
commit5c108ea34e2ea70be7f0fb266cd3db46b94d3585 (patch)
tree190de1d6fddb49f60c73d384280ca3c75db5d19a /server
parent18143dddcec64f6ba2a610f51abdb25272a8d129 (diff)
downloadvaadin-framework-5c108ea34e2ea70be7f0fb266cd3db46b94d3585.tar.gz
vaadin-framework-5c108ea34e2ea70be7f0fb266cd3db46b94d3585.zip
Do not call requestStart/end multiple times when using push (#14228)
All HTTP request based push request invoke onRequestStart/End in the servlet. We need to trigger start/end separately in push handler only for websocket messages Change-Id: I16064ea88b0c70812f247028ddb23560536db70d
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/communication/PushHandler.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java
index 93f1434c94..67e5f87153 100644
--- a/server/src/com/vaadin/server/communication/PushHandler.java
+++ b/server/src/com/vaadin/server/communication/PushHandler.java
@@ -71,9 +71,10 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter {
AtmosphereRequest req = resource.getRequest();
if (req.getMethod().equalsIgnoreCase("GET")) {
- callWithUi(resource, establishCallback);
+ callWithUi(resource, establishCallback, false);
} else if (req.getMethod().equalsIgnoreCase("POST")) {
- callWithUi(resource, receiveCallback);
+ callWithUi(resource, receiveCallback,
+ resource.transport() == TRANSPORT.WEBSOCKET);
}
}
@@ -200,15 +201,22 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter {
* the atmosphere resource for the current request
* @param callback
* the push callback to call when a UI is found and locked
+ * @param websocket
+ * true if this is a websocket message (as opposed to a HTTP
+ * request)
*/
private void callWithUi(final AtmosphereResource resource,
- final PushEventCallback callback) {
+ final PushEventCallback callback, boolean websocket) {
AtmosphereRequest req = resource.getRequest();
VaadinServletRequest vaadinRequest = new VaadinServletRequest(req,
service);
VaadinSession session = null;
- service.requestStart(vaadinRequest, null);
+ if (websocket) {
+ // For any HTTP request we have already started the request in the
+ // servlet
+ service.requestStart(vaadinRequest, null);
+ }
try {
try {
session = service.findVaadinSession(vaadinRequest);
@@ -279,7 +287,9 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter {
}
} finally {
try {
- service.requestEnd(vaadinRequest, null, session);
+ if (websocket) {
+ service.requestEnd(vaadinRequest, null, session);
+ }
} catch (Exception e) {
getLogger().log(Level.WARNING, "Error while ending request", e);