aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2014-06-26 12:11:44 +0300
committerLeif Åstrand <leif@vaadin.com>2014-07-01 09:12:52 +0000
commit264e617c58d537d12a03b5f3fb73f5129fcadc09 (patch)
treec02022030218e6e4f293f95ac5471755e5b81153 /server
parentf7e7f0e4f7ec4463863910ef66308dd71762acce (diff)
downloadvaadin-framework-264e617c58d537d12a03b5f3fb73f5129fcadc09.tar.gz
vaadin-framework-264e617c58d537d12a03b5f3fb73f5129fcadc09.zip
Add conf option for disabling sync id checking (#14084)
Change-Id: If3fcc88e69d797b219f5af5906853a42d81f693c
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/Constants.java1
-rw-r--r--server/src/com/vaadin/server/DefaultDeploymentConfiguration.java23
-rw-r--r--server/src/com/vaadin/server/DeploymentConfiguration.java11
-rw-r--r--server/src/com/vaadin/server/communication/ServerRpcHandler.java12
-rw-r--r--server/src/com/vaadin/server/communication/UidlWriter.java10
-rw-r--r--server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java10
6 files changed, 62 insertions, 5 deletions
diff --git a/server/src/com/vaadin/server/Constants.java b/server/src/com/vaadin/server/Constants.java
index 39329c32ce..34c9b5b767 100644
--- a/server/src/com/vaadin/server/Constants.java
+++ b/server/src/com/vaadin/server/Constants.java
@@ -126,6 +126,7 @@ public interface Constants {
static final String SERVLET_PARAMETER_PUSH_MODE = "pushMode";
static final String SERVLET_PARAMETER_UI_PROVIDER = "UIProvider";
static final String SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING = "legacyPropertyToString";
+ static final String SERVLET_PARAMETER_SYNC_ID_CHECK = "syncIdCheck";
// Configurable parameter names
static final String PARAMETER_VAADIN_RESOURCES = "Resources";
diff --git a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
index e72b411720..97790e7c0c 100644
--- a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
@@ -51,6 +51,11 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
*/
public static final LegacyProperyToStringMode DEFAULT_LEGACY_PROPERTY_TO_STRING = LegacyProperyToStringMode.WARNING;
+ /**
+ * Default value for {@link #isSyncIdCheckEnabled()} = {@value} .
+ */
+ public static final boolean DEFAULT_SYNC_ID_CHECK = true;
+
private final Properties initParameters;
private boolean productionMode;
private boolean xsrfProtectionEnabled;
@@ -60,6 +65,7 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
private PushMode pushMode;
private final Class<?> systemPropertyBaseClass;
private LegacyProperyToStringMode legacyPropertyToStringMode;
+ private boolean syncIdCheck;
/**
* Create a new deployment configuration instance.
@@ -83,6 +89,7 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
checkCloseIdleSessions();
checkPushMode();
checkLegacyPropertyToString();
+ checkSyncIdCheck();
}
private void checkLegacyPropertyToString() {
@@ -238,6 +245,16 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
/**
* {@inheritDoc}
* <p>
+ * The default value is <code>true</code>.
+ */
+ @Override
+ public boolean isSyncIdCheckEnabled() {
+ return syncIdCheck;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
* The default mode is {@link PushMode#DISABLED}.
*/
@Override
@@ -321,6 +338,12 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
}
}
+ private void checkSyncIdCheck() {
+ syncIdCheck = getApplicationOrSystemProperty(
+ Constants.SERVLET_PARAMETER_SYNC_ID_CHECK,
+ Boolean.toString(DEFAULT_SYNC_ID_CHECK)).equals("true");
+ }
+
private Logger getLogger() {
return Logger.getLogger(getClass().getName());
}
diff --git a/server/src/com/vaadin/server/DeploymentConfiguration.java b/server/src/com/vaadin/server/DeploymentConfiguration.java
index b600d01cbd..50d84812ea 100644
--- a/server/src/com/vaadin/server/DeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DeploymentConfiguration.java
@@ -85,6 +85,17 @@ public interface DeploymentConfiguration extends Serializable {
public boolean isXsrfProtectionEnabled();
/**
+ * Returns whether sync id checking is enabled. The sync id is used to
+ * gracefully handle situations when the client sends a message to a
+ * connector that has recently been removed on the server.
+ *
+ * @since
+ * @return <code>true</code> if sync id checking is enabled;
+ * <code>false</code> otherwise
+ */
+ public boolean isSyncIdCheckEnabled();
+
+ /**
* Returns the time resources can be cached in the browsers, in seconds.
*
* @return The resource cache time.
diff --git a/server/src/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/com/vaadin/server/communication/ServerRpcHandler.java
index 89d87567d7..36bfc8bcc6 100644
--- a/server/src/com/vaadin/server/communication/ServerRpcHandler.java
+++ b/server/src/com/vaadin/server/communication/ServerRpcHandler.java
@@ -75,10 +75,16 @@ public class ServerRpcHandler implements Serializable {
private final int syncId;
private final JSONObject json;
- public RpcRequest(String jsonString) throws JSONException {
+ public RpcRequest(String jsonString, VaadinRequest request)
+ throws JSONException {
json = new JSONObject(jsonString);
csrfToken = json.getString(ApplicationConstants.CSRF_TOKEN);
- syncId = json.getInt(ApplicationConstants.SERVER_SYNC_ID);
+ if (request.getService().getDeploymentConfiguration()
+ .isSyncIdCheckEnabled()) {
+ syncId = json.getInt(ApplicationConstants.SERVER_SYNC_ID);
+ } else {
+ syncId = -1;
+ }
invocations = new JSONArray(
json.getString(ApplicationConstants.RPC_INVOCATIONS));
}
@@ -157,7 +163,7 @@ public class ServerRpcHandler implements Serializable {
return;
}
- RpcRequest rpcRequest = new RpcRequest(changeMessage);
+ RpcRequest rpcRequest = new RpcRequest(changeMessage, request);
// Security: double cookie submission pattern unless disabled by
// property
diff --git a/server/src/com/vaadin/server/communication/UidlWriter.java b/server/src/com/vaadin/server/communication/UidlWriter.java
index 00522e2aa5..9d55f7e197 100644
--- a/server/src/com/vaadin/server/communication/UidlWriter.java
+++ b/server/src/com/vaadin/server/communication/UidlWriter.java
@@ -37,6 +37,7 @@ import com.vaadin.server.JsonPaintTarget;
import com.vaadin.server.LegacyCommunicationManager;
import com.vaadin.server.LegacyCommunicationManager.ClientCache;
import com.vaadin.server.SystemMessages;
+import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.ui.ConnectorTracker;
@@ -75,10 +76,11 @@ public class UidlWriter implements Serializable {
public void write(UI ui, Writer writer, boolean repaintAll, boolean async)
throws IOException, JSONException {
VaadinSession session = ui.getSession();
+ VaadinService service = session.getService();
// Purge pending access calls as they might produce additional changes
// to write out
- session.getService().runPendingAccessTasks(session);
+ service.runPendingAccessTasks(session);
ArrayList<ClientConnector> dirtyVisibleConnectors = ui
.getConnectorTracker().getDirtyVisibleConnectors();
@@ -99,8 +101,12 @@ public class UidlWriter implements Serializable {
uiConnectorTracker.setWritingResponse(true);
try {
+
+ int syncId = service.getDeploymentConfiguration()
+ .isSyncIdCheckEnabled() ? uiConnectorTracker
+ .getCurrentSyncId() : -1;
writer.write("\"" + ApplicationConstants.SERVER_SYNC_ID + "\": "
- + uiConnectorTracker.getCurrentSyncId() + ", ");
+ + syncId + ", ");
writer.write("\"changes\" : ");
diff --git a/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java b/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java
index d113efdfaf..fe7f9ba03e 100644
--- a/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java
+++ b/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java
@@ -19,6 +19,7 @@ public class MockDeploymentConfiguration implements DeploymentConfiguration {
private Properties initParameters = new Properties();
private Map<String, String> applicationOrSystemProperty = new HashMap<String, String>();
private LegacyProperyToStringMode legacyPropertyToStringMode = LegacyProperyToStringMode.DISABLED;
+ private boolean syncIdCheckEnabled = true;
@Override
public boolean isProductionMode() {
@@ -34,6 +35,15 @@ public class MockDeploymentConfiguration implements DeploymentConfiguration {
return xsrfProtectionEnabled;
}
+ @Override
+ public boolean isSyncIdCheckEnabled() {
+ return syncIdCheckEnabled;
+ }
+
+ public void setSyncIdCheckEnabled(boolean syncIdCheckEnabled) {
+ this.syncIdCheckEnabled = syncIdCheckEnabled;
+ }
+
public void setXsrfProtectionEnabled(boolean xsrfProtectionEnabled) {
this.xsrfProtectionEnabled = xsrfProtectionEnabled;
}