summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-03-07 09:46:33 +0200
committerAleksi Hietanen <aleksi@vaadin.com>2017-03-07 09:46:33 +0200
commitf25041bfabd1e3b13a2a9bd85289098d33699cc2 (patch)
tree50492125a7b5359c1704db9b600ffacd466574eb /server
parent0c30d18856ed9d24868e9e9c53d1b16d9863efc9 (diff)
downloadvaadin-framework-f25041bfabd1e3b13a2a9bd85289098d33699cc2.tar.gz
vaadin-framework-f25041bfabd1e3b13a2a9bd85289098d33699cc2.zip
Handle unknown connectors consistently and quietly as described in #8111 (#8741)
Fixes #8629
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java20
-rw-r--r--server/src/test/java/com/vaadin/server/communication/ServerRpcHandlerTest.java49
2 files changed, 63 insertions, 6 deletions
diff --git a/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java
index d0be98332c..39b2621207 100644
--- a/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java
+++ b/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java
@@ -351,11 +351,9 @@ public class ServerRpcHandler implements Serializable {
final ClientConnector connector = connectorTracker
.getConnector(invocation.getConnectorId());
if (connector == null) {
- getLogger().log(Level.WARNING,
- "Received RPC call for unknown connector with id {0} (tried to invoke {1}.{2})",
- new Object[] { invocation.getConnectorId(),
- invocation.getInterfaceName(),
- invocation.getMethodName() });
+ logUnknownConnector(invocation.getConnectorId(),
+ invocation.getInterfaceName(),
+ invocation.getMethodName());
continue;
}
@@ -415,6 +413,13 @@ public class ServerRpcHandler implements Serializable {
}
}
+ private void logUnknownConnector(String connectorId, String interfaceName,
+ String methodName) {
+ getLogger().log(Level.FINE,
+ "Received RPC call for unknown connector with id {0} (tried to invoke {1}.{2})",
+ new Object[] { connectorId, interfaceName, methodName });
+ }
+
/**
* Handles the given RPC method invocation for the given connector
*
@@ -567,7 +572,10 @@ public class ServerRpcHandler implements Serializable {
JsonArray parametersJson, ConnectorTracker connectorTracker)
throws JsonException {
ClientConnector connector = connectorTracker.getConnector(connectorId);
-
+ if (connector == null) {
+ logUnknownConnector(connectorId, interfaceName, methodName);
+ return null;
+ }
ServerRpcManager<?> rpcManager = connector.getRpcManager(interfaceName);
if (rpcManager == null) {
/*
diff --git a/server/src/test/java/com/vaadin/server/communication/ServerRpcHandlerTest.java b/server/src/test/java/com/vaadin/server/communication/ServerRpcHandlerTest.java
new file mode 100644
index 0000000000..70ef0f4fb9
--- /dev/null
+++ b/server/src/test/java/com/vaadin/server/communication/ServerRpcHandlerTest.java
@@ -0,0 +1,49 @@
+package com.vaadin.server.communication;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinService;
+import com.vaadin.tests.util.AlwaysLockedVaadinSession;
+import com.vaadin.ui.UI;
+
+import elemental.json.Json;
+import elemental.json.JsonArray;
+
+public class ServerRpcHandlerTest {
+
+ public static class TestUI extends UI {
+
+ @Override
+ protected void init(VaadinRequest request) {
+
+ }
+
+ }
+
+ @Test
+ public void handleUnknownConnector() {
+ ServerRpcHandler rpcHandler = new ServerRpcHandler();
+ JsonArray invocation = Json.createArray();
+ invocation.set(0, "12");
+ invocation.set(1, "someInterface");
+ invocation.set(2, "someMethod");
+ JsonArray params = Json.createArray();
+ invocation.set(3, params);
+
+ JsonArray invocationData = Json.createArray();
+ invocationData.set(0, invocation);
+
+ AlwaysLockedVaadinSession s = new AlwaysLockedVaadinSession(
+ Mockito.mock(VaadinService.class));
+ TestUI ui = new TestUI();
+ ui.doInit(Mockito.mock(VaadinRequest.class), 1, null);
+ ui.setSession(s);
+ s.addUI(ui);
+ rpcHandler.handleInvocations(ui, 1, invocationData);
+
+ // This only tests that an invocation for a non-existant connector does
+ // not cause any exceptions
+ }
+}