From cfdb68344975953f6e7f0c83daf3bc078a26bf93 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 4 Apr 2016 18:17:11 -0400 Subject: [PATCH] Call resetRequest after writeFrame for polling sessions Previous refactoring (fcf6ae and also 43d937) in the SockJsSession hierarchy consolidated access to the request and response in the base class AbstractHttpSockJsSession in order to keep synchronization concerns there. However that also unintentionally removed the call to resetRequest() after sending a heartbeat for any of the PollingSockJsSession classes. In general a polling session should call resetRequest after every frame written. This commit brings back the writeFrame override in PollingSockJsSession with an extra call to resetRequest(). Issue: SPR-14107 --- .../sockjs/transport/session/PollingSockJsSession.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/PollingSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/PollingSockJsSession.java index 5bf23b006e..e3cb44882e 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/PollingSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/PollingSockJsSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,6 @@ public class PollingSockJsSession extends AbstractHttpSockJsSession { if (initialRequest) { writeFrame(SockJsFrame.openFrame()); - resetRequest(); } else if (!getMessageCache().isEmpty()) { flushCache(); @@ -77,6 +76,11 @@ public class PollingSockJsSession extends AbstractHttpSockJsSession { SockJsMessageCodec messageCodec = getSockJsServiceConfig().getMessageCodec(); SockJsFrame frame = SockJsFrame.messageFrame(messageCodec, messages); writeFrame(frame); + } + + @Override + protected void writeFrame(SockJsFrame frame) throws SockJsTransportFailureException { + super.writeFrame(frame); resetRequest(); }