Unverified 提交 dbf539fe authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1123 from katzyn/tcp_version

Fix TCP version check
...@@ -89,13 +89,17 @@ public class TcpServerThread implements Runnable { ...@@ -89,13 +89,17 @@ 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 < 6) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + minClientVersion, "" + Constants.TCP_PROTOCOL_VERSION_MIN_SUPPORTED);
}
int maxClientVersion = transfer.readInt(); int maxClientVersion = transfer.readInt();
if (maxClientVersion < Constants.TCP_PROTOCOL_VERSION_MIN_SUPPORTED) { if (maxClientVersion < Constants.TCP_PROTOCOL_VERSION_MIN_SUPPORTED) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2, throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_MIN_SUPPORTED); "" + maxClientVersion, "" + Constants.TCP_PROTOCOL_VERSION_MIN_SUPPORTED);
} else if (minClientVersion > Constants.TCP_PROTOCOL_VERSION_MAX_SUPPORTED) { } else if (minClientVersion > Constants.TCP_PROTOCOL_VERSION_MAX_SUPPORTED) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2, throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_MAX_SUPPORTED); "" + minClientVersion, "" + Constants.TCP_PROTOCOL_VERSION_MAX_SUPPORTED);
} }
if (maxClientVersion >= Constants.TCP_PROTOCOL_VERSION_MAX_SUPPORTED) { if (maxClientVersion >= Constants.TCP_PROTOCOL_VERSION_MAX_SUPPORTED) {
clientVersion = Constants.TCP_PROTOCOL_VERSION_MAX_SUPPORTED; clientVersion = Constants.TCP_PROTOCOL_VERSION_MAX_SUPPORTED;
......
...@@ -141,7 +141,14 @@ public class TestOldVersion extends TestBase { ...@@ -141,7 +141,14 @@ public class TestOldVersion extends TestBase {
private static ClassLoader getClassLoader(String jarFile) throws Exception { private static ClassLoader getClassLoader(String jarFile) throws Exception {
URL[] urls = { new URL(jarFile) }; URL[] urls = { new URL(jarFile) };
return new URLClassLoader(urls, null); return new URLClassLoader(urls, null) {
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
if (name.startsWith("org.h2."))
return super.loadClass(name, resolve);
return TestOldVersion.class.getClassLoader().loadClass(name);
}
};
} }
private static Driver getDriver(ClassLoader cl) throws Exception { private static Driver getDriver(ClassLoader cl) throws Exception {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论