aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-04-14 17:28:59 +0300
committerArtur Signell <artur@vaadin.com>2015-07-13 17:11:07 +0300
commit7dcba4ed859d53f3173c33ea3e2151d158e50968 (patch)
tree446007cb27393c0e2214bdc280393ba63730421b
parent09526e4b7fd7e8253a3234b7b9fb7e9257e6f34c (diff)
downloadvaadin-framework-7dcba4ed859d53f3173c33ea3e2151d158e50968.tar.gz
vaadin-framework-7dcba4ed859d53f3173c33ea3e2151d158e50968.zip
Do not send empty server requests (#11733)
Change-Id: Icacc102132ac4fbd8e00f97b3a752f2483cf3936
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java111
-rw-r--r--client/src/com/vaadin/client/ui/VUpload.java7
-rw-r--r--server/src/com/vaadin/ui/Upload.java5
-rw-r--r--shared/src/com/vaadin/shared/ui/upload/UploadServerRpc.java8
4 files changed, 79 insertions, 52 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 1d6d09c262..51ab2120f6 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -2783,66 +2783,75 @@ public class ApplicationConnection implements HasHandlers {
private void sendInvocationsToServer() {
boolean showLoadingIndicator = false;
JsonArray reqJson = Json.createArray();
- if (!pendingInvocations.isEmpty()) {
- if (ApplicationConfiguration.isDebugMode()) {
- Util.logMethodInvocations(this, pendingInvocations.values());
+ if (pendingInvocations.isEmpty()) {
+ return;
+ }
+
+ if (ApplicationConfiguration.isDebugMode()) {
+ Util.logMethodInvocations(this, pendingInvocations.values());
+ }
+
+ for (MethodInvocation invocation : pendingInvocations.values()) {
+ String connectorId = invocation.getConnectorId();
+ if (!getConnectorMap().connectorExists(connectorId)) {
+ getLogger().info(
+ "Not sending RPC for removed connector: " + connectorId
+ + ": "
+ + Util.getInvocationDebugString(invocation));
+ continue;
}
- for (MethodInvocation invocation : pendingInvocations.values()) {
- String connectorId = invocation.getConnectorId();
- if (!getConnectorMap().connectorExists(connectorId)) {
- getLogger()
- .info("Not sending RPC for removed connector: "
- + connectorId + ": "
- + Util.getInvocationDebugString(invocation));
- continue;
- }
+ JsonArray invocationJson = Json.createArray();
+ invocationJson.set(0, connectorId);
+ invocationJson.set(1, invocation.getInterfaceName());
+ invocationJson.set(2, invocation.getMethodName());
+ JsonArray paramJson = Json.createArray();
- JsonArray invocationJson = Json.createArray();
- invocationJson.set(0, connectorId);
- invocationJson.set(1, invocation.getInterfaceName());
- invocationJson.set(2, invocation.getMethodName());
- JsonArray paramJson = Json.createArray();
+ Type[] parameterTypes = null;
+ if (!isLegacyVariableChange(invocation)
+ && !isJavascriptRpc(invocation)) {
+ try {
+ Type type = new Type(invocation.getInterfaceName(), null);
+ Method method = type.getMethod(invocation.getMethodName());
+ parameterTypes = method.getParameterTypes();
- Type[] parameterTypes = null;
- if (!isLegacyVariableChange(invocation)
- && !isJavascriptRpc(invocation)) {
- try {
- Type type = new Type(invocation.getInterfaceName(),
- null);
- Method method = type.getMethod(invocation
- .getMethodName());
- parameterTypes = method.getParameterTypes();
-
- showLoadingIndicator |= !TypeDataStore
- .isNoLoadingIndicator(method);
- } catch (NoDataException e) {
- throw new RuntimeException("No type data for "
- + invocation.toString(), e);
- }
- } else {
- // Always show loading indicator for legacy requests
- showLoadingIndicator = true;
+ showLoadingIndicator |= !TypeDataStore
+ .isNoLoadingIndicator(method);
+ } catch (NoDataException e) {
+ throw new RuntimeException("No type data for "
+ + invocation.toString(), e);
}
+ } else {
+ // Always show loading indicator for legacy requests
+ showLoadingIndicator = true;
+ }
- for (int i = 0; i < invocation.getParameters().length; ++i) {
- // TODO non-static encoder?
- Type type = null;
- if (parameterTypes != null) {
- type = parameterTypes[i];
- }
- Object value = invocation.getParameters()[i];
- JsonValue jsonValue = JsonEncoder.encode(value, type, this);
- paramJson.set(i, jsonValue);
+ for (int i = 0; i < invocation.getParameters().length; ++i) {
+ // TODO non-static encoder?
+ Type type = null;
+ if (parameterTypes != null) {
+ type = parameterTypes[i];
}
- invocationJson.set(3, paramJson);
- reqJson.set(reqJson.length(), invocationJson);
+ Object value = invocation.getParameters()[i];
+ JsonValue jsonValue = JsonEncoder.encode(value, type, this);
+ paramJson.set(i, jsonValue);
}
+ invocationJson.set(3, paramJson);
+ reqJson.set(reqJson.length(), invocationJson);
+ }
+
+ pendingInvocations.clear();
+ // Keep tag string short
+ lastInvocationTag = 0;
+ sendServerRpcWhenConnectionAvailable = false;
- pendingInvocations.clear();
- // Keep tag string short
- lastInvocationTag = 0;
- sendServerRpcWhenConnectionAvailable = false;
+ if (reqJson.length() == 0) {
+ // Nothing to send, all invocations were filtered out (for
+ // non-existing connectors)
+ getLogger()
+ .warning(
+ "All RPCs filtered out, not sending anything to the server");
+ return;
}
String extraParams = "";
diff --git a/client/src/com/vaadin/client/ui/VUpload.java b/client/src/com/vaadin/client/ui/VUpload.java
index dff45a6951..2800acccf9 100644
--- a/client/src/com/vaadin/client/ui/VUpload.java
+++ b/client/src/com/vaadin/client/ui/VUpload.java
@@ -36,9 +36,12 @@ import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo;
+import com.vaadin.client.ConnectorMap;
import com.vaadin.client.StyleConstants;
import com.vaadin.client.VConsole;
+import com.vaadin.client.ui.upload.UploadConnector;
import com.vaadin.client.ui.upload.UploadIFrameOnloadStrategy;
+import com.vaadin.shared.ui.upload.UploadServerRpc;
/**
*
@@ -246,7 +249,9 @@ public class VUpload extends SimplePanel {
t.cancel();
}
VConsole.log("VUpload:Submit complete");
- client.sendPendingVariableChanges();
+ ((UploadConnector) ConnectorMap.get(client)
+ .getConnector(VUpload.this)).getRpcProxy(
+ UploadServerRpc.class).poll();
}
rebuildPanel();
diff --git a/server/src/com/vaadin/ui/Upload.java b/server/src/com/vaadin/ui/Upload.java
index 693bd74dbf..2da7db53b5 100644
--- a/server/src/com/vaadin/ui/Upload.java
+++ b/server/src/com/vaadin/ui/Upload.java
@@ -121,6 +121,11 @@ public class Upload extends AbstractComponent implements Component.Focusable,
public void change(String filename) {
fireEvent(new ChangeEvent(Upload.this, filename));
}
+
+ @Override
+ public void poll() {
+ // Nothing to do, called only to visit the server
+ }
});
}
diff --git a/shared/src/com/vaadin/shared/ui/upload/UploadServerRpc.java b/shared/src/com/vaadin/shared/ui/upload/UploadServerRpc.java
index b576eb9114..b353057ab3 100644
--- a/shared/src/com/vaadin/shared/ui/upload/UploadServerRpc.java
+++ b/shared/src/com/vaadin/shared/ui/upload/UploadServerRpc.java
@@ -27,4 +27,12 @@ public interface UploadServerRpc extends ServerRpc {
*/
void change(String filename);
+ /**
+ * Called to poll the server to see if any changes have been made e.g. when
+ * starting upload
+ *
+ * @since
+ */
+ void poll();
+
}