Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove message start (#12013) (CP: 2.7) #12140

Merged
merged 1 commit into from
Oct 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()}.
Expand Down