]> source.dussan.org Git - vaadin-framework.git/commitdiff
Ignore -1 sync id on the server (#14084)
authorLeif Åstrand <leif@vaadin.com>
Wed, 25 Jun 2014 11:42:30 +0000 (14:42 +0300)
committerVaadin Code Review <review@vaadin.com>
Tue, 1 Jul 2014 09:12:45 +0000 (09:12 +0000)
Change-Id: Iad73c44852c207f29381d59bea25275ac8f24dbd

server/src/com/vaadin/ui/ConnectorTracker.java
shared/src/com/vaadin/shared/ApplicationConstants.java

index f7eae0013a675fffaccbc8eafc462c829ab11959..c0f973106be9fd651b63a78d2ab367cd05cf08c2 100644 (file)
@@ -774,7 +774,7 @@ public class ConnectorTracker implements Serializable {
      *            concurrently or not.
      * @param lastSyncIdSeenByClient
      *            the most recent sync id the client has seen at the time the
-     *            request was sent
+     *            request was sent, or -1 to ignore potential problems
      * @return <code>true</code> if the connector was removed before the client
      *         had a chance to react to it.
      */
@@ -784,7 +784,8 @@ public class ConnectorTracker implements Serializable {
         assert getConnector(connectorId) == null : "Connector " + connectorId
                 + " is still attached";
 
-        boolean clientRequestIsTooOld = lastSyncIdSeenByClient < currentSyncId;
+        boolean clientRequestIsTooOld = lastSyncIdSeenByClient < currentSyncId
+                && lastSyncIdSeenByClient != -1;
         if (clientRequestIsTooOld) {
             /*
              * The headMap call is present here because we're only interested in
@@ -823,6 +824,9 @@ public class ConnectorTracker implements Serializable {
      * packet is sent. If the state has changed on the server side since that,
      * the server can try to adjust the way it handles the actions from the
      * client side.
+     * <p>
+     * The sync id value <code>-1</code> is ignored to facilitate testing with
+     * pre-recorded requests.
      * 
      * @see #setWritingResponse(boolean)
      * @see #connectorWasPresentAsRequestWasSent(String, long)
@@ -846,6 +850,9 @@ public class ConnectorTracker implements Serializable {
      * Entries that both client and server agree upon are removed. Since
      * argument is the last sync id that the client has seen from the server, we
      * know that entries earlier than that cannot cause any problems anymore.
+     * <p>
+     * The sync id value <code>-1</code> is ignored to facilitate testing with
+     * pre-recorded requests.
      * 
      * @see #connectorWasPresentAsRequestWasSent(String, long)
      * @since 7.2
@@ -854,6 +861,12 @@ public class ConnectorTracker implements Serializable {
      *            server.
      */
     public void cleanConcurrentlyRemovedConnectorIds(int lastSyncIdSeenByClient) {
+        if (lastSyncIdSeenByClient == -1) {
+            // Sync id checking is not in use, so we should just clear the
+            // entire map to avoid leaking memory
+            syncIdToUnregisteredConnectorIds.clear();
+            return;
+        }
         /*
          * We remove all entries _older_ than the one reported right now,
          * because the remaining still contain components that might cause
index 9f723763f8291522a99a53a3a622f3faf54d7066..da4ac7450d9020dab9ee79ad10a3bbb64904d3cc 100644 (file)
@@ -111,7 +111,9 @@ public class ApplicationConstants implements Serializable {
     public static final String CSRF_TOKEN = "csrfToken";
 
     /**
-     * The name of the parameter used to transmit the sync id
+     * The name of the parameter used to transmit the sync id. The value can be
+     * set to -1 e.g. when testing with pre-recorded requests to make the
+     * framework ignore the sync id.
      * 
      * @see com.vaadin.ui.ConnectorTracker#getCurrentSyncId()
      * @since 7.2