diff --git a/flow-server/src/main/java/com/vaadin/flow/server/communication/ServerRpcHandler.java b/flow-server/src/main/java/com/vaadin/flow/server/communication/ServerRpcHandler.java index 69add2aae03..716a323823a 100644 --- a/flow-server/src/main/java/com/vaadin/flow/server/communication/ServerRpcHandler.java +++ b/flow-server/src/main/java/com/vaadin/flow/server/communication/ServerRpcHandler.java @@ -303,15 +303,15 @@ public void handleRpc(UI ui, Reader reader, VaadinRequest request) * implementing the resync that would thus hide most symptoms of * the actual root cause bugs. */ - String messageStart = changeMessage; - if (messageStart.length() > 1000) { - messageStart = messageStart.substring(0, 1000); - } + String messageDetails = getMessageDetails(rpcRequest); + getLogger().debug("Unexpected message id from the client." + + " Expected sync id: " + expectedId + ", got " + + requestId + ". Message start: " + messageDetails); throw new UnsupportedOperationException( "Unexpected message id from the client." + " Expected sync id: " + expectedId + ", got " - + requestId + ". Message start: " - + messageStart); + + requestId + + ". more details logged on DEBUG level."); } } else { // Message id ok, process RPCs @@ -342,6 +342,32 @@ public void handleRpc(UI ui, Reader reader, VaadinRequest request) } } + private String getMessageDetails(RpcRequest rpcRequest) { + StringBuilder messageDetails = new StringBuilder(); + JsonArray rpcArray = rpcRequest.getRpcInvocationsData(); + if (rpcArray == null) { + return "{ no data }"; + } + + for (int i = 0; i < rpcArray.length(); i++) { + JsonObject json = rpcArray.get(i); + String type = json.hasKey("type") ? json.getString("type") : ""; + Double node = json.hasKey("node") ? json.getNumber("node") : null; + Double feature = json.hasKey("feature") ? json.getNumber("feature") + : null; + appendAll(messageDetails, "{ type: ", type, " node: ", + String.valueOf(node), " feature: ", String.valueOf(feature), + " } "); + } + return messageDetails.toString(); + } + + private static void appendAll(StringBuilder builder, String... strings) { + for (String string : strings) { + builder.append(string); + } + } + /** * Gets {@link RpcInvocationHandler}s map where the key is the type of the * handler gotten via {@link RpcInvocationHandler#getRpcType()}.