提交 92176172 authored 作者: Piotr Dubrovskiy's avatar Piotr Dubrovskiy

fix protocol version resolution logic to choose the highest version supported by client and server

上级 3eee97d7
...@@ -82,18 +82,18 @@ public class TcpServerThread implements Runnable { ...@@ -82,18 +82,18 @@ public class TcpServerThread implements Runnable {
throw DbException.get(ErrorCode.REMOTE_CONNECTION_NOT_ALLOWED); throw DbException.get(ErrorCode.REMOTE_CONNECTION_NOT_ALLOWED);
} }
int minClientVersion = transfer.readInt(); int minClientVersion = transfer.readInt();
if (minClientVersion < Constants.TCP_PROTOCOL_VERSION_6) { int maxClientVersion = transfer.readInt();
if (maxClientVersion < Constants.TCP_PROTOCOL_VERSION_6) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2, throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_6); "" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_6);
} else if (minClientVersion > Constants.TCP_PROTOCOL_VERSION_16) { } else if (minClientVersion > Constants.TCP_PROTOCOL_VERSION_16) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2, throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_16); "" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_16);
} }
int maxClientVersion = transfer.readInt();
if (maxClientVersion >= Constants.TCP_PROTOCOL_VERSION_16) { if (maxClientVersion >= Constants.TCP_PROTOCOL_VERSION_16) {
clientVersion = Constants.TCP_PROTOCOL_VERSION_16; clientVersion = Constants.TCP_PROTOCOL_VERSION_16;
} else { } else {
clientVersion = minClientVersion; clientVersion = maxClientVersion;
} }
transfer.setVersion(clientVersion); transfer.setVersion(clientVersion);
String db = transfer.readString(); String db = transfer.readString();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论