You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2020/08/04 09:55:01 UTC
[shardingsphere] branch master updated: Fix set null error for
MySQLServerInfo (#6616)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 274848c Fix set null error for MySQLServerInfo (#6616)
274848c is described below
commit 274848c1021c27aa24cf423650c318df01f7e135
Author: Liang Zhang <te...@163.com>
AuthorDate: Tue Aug 4 17:54:52 2020 +0800
Fix set null error for MySQLServerInfo (#6616)
* Fix checkstyle error
* Fix set null error for MySQLServerInfo
---
.../shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java | 2 +-
.../db/protocol/mysql/constant/MySQLServerInfoTest.java | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java
index 8392e28..dff6ad1 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java
@@ -50,7 +50,7 @@ public final class MySQLServerInfo {
* @param serverVersion server version
*/
public static synchronized void setServerVersion(final String serverVersion) {
- MySQLServerInfo.serverVersion = String.format(SERVER_VERSION_PATTERN, serverVersion, PROXY_VERSION);
+ MySQLServerInfo.serverVersion = null == serverVersion ? null : String.format(SERVER_VERSION_PATTERN, serverVersion, PROXY_VERSION);
}
/**
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfoTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfoTest.java
index 8f31395..c487255 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfoTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfoTest.java
@@ -23,16 +23,16 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public final class MySQLServerInfoTest {
-
+
@Test
public void assertSetServerVersion() {
MySQLServerInfo.setServerVersion("5.1.47");
assertThat(MySQLServerInfo.getServerVersion(), is("5.1.47-ShardingSphere-Proxy 5.0.0-RC1"));
}
-
+
@Test
public void assertSetServerVersionForNull() {
MySQLServerInfo.setServerVersion(null);
- assertThat(MySQLServerInfo.getServerVersion(), is("null-ShardingSphere-Proxy 5.0.0-RC1"));
+ assertThat(MySQLServerInfo.getServerVersion(), is("8.0.20-ShardingSphere-Proxy 5.0.0-RC1"));
}
}