ptupitsyn commented on code in PR #949:
URL: https://github.com/apache/ignite-3/pull/949#discussion_r925928901
##########
modules/client/src/main/java/org/apache/ignite/internal/client/TcpClientChannel.java:
##########
@@ -291,30 +271,58 @@ private void processNextMessage(ByteBuf buf) throws
IgniteClientException {
var type = unpacker.unpackInt();
if (type != ServerMessageType.RESPONSE) {
- throw new IgniteClientException("Unexpected message type: " +
type);
+ throw new IgniteClientConnectionException(PROTOCOL_ERR,
"Unexpected message type: " + type);
}
Long resId = unpacker.unpackLong();
- int status = unpacker.unpackInt();
-
ClientRequestFuture pendingReq = pendingReqs.remove(resId);
if (pendingReq == null) {
- throw new IgniteClientException(String.format("Unexpected response
ID [%s]", resId));
+ throw new IgniteClientConnectionException(PROTOCOL_ERR,
String.format("Unexpected response ID [%s]", resId));
}
- if (status == 0) {
+ if (unpacker.tryUnpackNil()) {
pendingReq.complete(unpacker);
} else {
- var errMsg = unpacker.unpackString();
+ IgniteException err = readError(unpacker);
+
unpacker.close();
- var err = new IgniteClientException(errMsg, status);
pendingReq.completeExceptionally(err);
}
}
+ /**
+ * Unpacks request error.
+ *
+ * @param unpacker Unpacker.
+ * @return Exception.
+ */
+ private IgniteException readError(ClientMessageUnpacker unpacker) {
+ var traceId = unpacker.tryUnpackNil() ? UUID.randomUUID() :
unpacker.unpackUuid();
Review Comment:
This code is not correct - the server always sends `traceId` and `code`, no
need for nil checks here. Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]