From c598a852c2565b67226533622b5f75a3b588acf3 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 21 Jan 2013 21:46:47 +0200 Subject: [PATCH] Handle OutOfSync by resyncing automatically (#10780) Change-Id: I5958d82b09519dabe9f2af792bd216d3b426c1c9 --- .../server/AbstractCommunicationManager.java | 17 ++++-- .../tests/components/OutOfSyncTest.html | 38 +++++++++++++ .../tests/components/OutOfSyncTest.java | 55 +++++++++++++++++++ 3 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/OutOfSyncTest.html create mode 100644 uitest/src/com/vaadin/tests/components/OutOfSyncTest.java diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index c1c18901b4..cd7279e601 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -1780,11 +1780,18 @@ public abstract class AbstractCommunicationManager implements Serializable { if (connectorTracker.getConnector(connectorId) == null && !connectorId .equals(ApplicationConstants.DRAG_AND_DROP_CONNECTOR_ID)) { - getLogger().log( - Level.WARNING, - "RPC call to " + interfaceName + "." + methodName - + " received for connector " + connectorId - + " but no such connector could be found"); + getLogger() + .log(Level.WARNING, + "RPC call to " + + interfaceName + + "." + + methodName + + " received for connector " + + connectorId + + " but no such connector could be found. Resynchronizing client."); + // This is likely an out of sync issue (client tries to update a + // connector which is not present). Force resync. + connectorTracker.markAllConnectorsDirty(); return null; } diff --git a/uitest/src/com/vaadin/tests/components/OutOfSyncTest.html b/uitest/src/com/vaadin/tests/components/OutOfSyncTest.html new file mode 100644 index 0000000000..4828069e2a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/OutOfSyncTest.html @@ -0,0 +1,38 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/OutOfSyncTest?restartApplication
pause1000
clickvaadin=runOutOfSyncTest::/VButton[0]/domChild[0]/domChild[0]
assertElementNotPresentvaadin=runOutOfSyncTest::/VButton[0]
+ + diff --git a/uitest/src/com/vaadin/tests/components/OutOfSyncTest.java b/uitest/src/com/vaadin/tests/components/OutOfSyncTest.java new file mode 100644 index 0000000000..0efb519e8d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/OutOfSyncTest.java @@ -0,0 +1,55 @@ +package com.vaadin.tests.components; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Notification; + +public class OutOfSyncTest extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Button b = new Button("Click me after 1s to be out of sync"); + b.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Notification.show("This code will never be reached"); + } + }); + setContent(b); + Thread t = new Thread(new Runnable() { + + @Override + public void run() { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + // Remove button but prevent repaint -> causes out of sync + // issues + getSession().lock(); + try { + setContent(null); + getConnectorTracker().markClean(OutOfSyncTest.this); + } finally { + getSession().unlock(); + } + } + }); + t.start(); + } + + @Override + protected String getTestDescription() { + return "Click the button after 1s when it has been removed server side (causing synchronization problems)"; + } + + @Override + protected Integer getTicketNumber() { + return 10780; + } + +} -- 2.39.5