You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2023/05/09 05:57:24 UTC
[shardingsphere] branch master updated: Code cleanup in MySQLServerInfo (#25533)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 7a058d7cdbe Code cleanup in MySQLServerInfo (#25533)
7a058d7cdbe is described below
commit 7a058d7cdbe0978c5998e32658389c5449765fc6
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Tue May 9 13:57:15 2023 +0800
Code cleanup in MySQLServerInfo (#25533)
---
.../db/protocol/mysql/constant/MySQLServerInfo.java | 15 +++------------
.../db/protocol/mysql/constant/MySQLServerInfoTest.java | 2 +-
2 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java
index 5608aca7641..c92b7af3587 100644
--- a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java
+++ b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java
@@ -37,10 +37,10 @@ public final class MySQLServerInfo {
public static final MySQLCharacterSet DEFAULT_CHARSET = MySQLCharacterSet.UTF8MB4_GENERAL_CI;
- private static String defaultMysqlVersion = "5.7.22";
-
private static final String SERVER_VERSION_PATTERN = "%s-ShardingSphere-Proxy %s";
+ private static final String DEFAULT_MYSQL_VERSION = "5.7.22";
+
private static final Map<String, String> SERVER_VERSIONS = new ConcurrentHashMap<>();
/**
@@ -63,21 +63,12 @@ public final class MySQLServerInfo {
return null == databaseName ? getDefaultServerVersion() : SERVER_VERSIONS.getOrDefault(databaseName, getDefaultServerVersion());
}
- /**
- * Set default MySQL version.
- *
- * @param defaultMysqlVersion default MySQL version
- */
- public static void setDefaultMysqlVersion(final String defaultMysqlVersion) {
- MySQLServerInfo.defaultMysqlVersion = defaultMysqlVersion;
- }
-
/**
* Get default server version.
*
* @return server version
*/
public static String getDefaultServerVersion() {
- return String.format(SERVER_VERSION_PATTERN, defaultMysqlVersion, CommonConstants.PROXY_VERSION.get());
+ return String.format(SERVER_VERSION_PATTERN, DEFAULT_MYSQL_VERSION, CommonConstants.PROXY_VERSION.get());
}
}
diff --git a/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfoTest.java b/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfoTest.java
index cb1b1336fb3..837c7ccf9d2 100644
--- a/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfoTest.java
+++ b/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfoTest.java
@@ -34,7 +34,7 @@ class MySQLServerInfoTest {
}
@Test
- void assertSetServerVersionForNull() {
+ void assertGetDefaultServerVersion() {
CommonConstants.PROXY_VERSION.set("5.0.0");
assertThat(MySQLServerInfo.getDefaultServerVersion(), is("5.7.22-ShardingSphere-Proxy 5.0.0"));
}