You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/10/01 12:08:48 UTC
[shardingsphere] branch master updated: Add MySQLProtocolException (#21303)
This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 e0d9ce4704b Add MySQLProtocolException (#21303)
e0d9ce4704b is described below
commit e0d9ce4704bd2485e6896992f4a0bcb4ab779d87
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Oct 1 20:08:40 2022 +0800
Add MySQLProtocolException (#21303)
---
.../mysql/constant/MySQLNewParametersBoundFlag.java | 3 ++-
.../protocol/mysql/exception/MySQLProtocolException.java | 14 +++++++++-----
.../mysql/constant/MySQLNewParametersBoundFlagTest.java | 3 ++-
.../dialect/exception/SQLDialectException.java | 6 ++++++
4 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlag.java b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlag.java
index 29919c2fc03..1fff72932f7 100644
--- a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlag.java
+++ b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlag.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.db.protocol.mysql.constant;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.db.protocol.mysql.exception.MySQLProtocolException;
/**
* New parameters bound flag for MySQL.
@@ -47,6 +48,6 @@ public enum MySQLNewParametersBoundFlag {
return each;
}
}
- throw new IllegalArgumentException(String.format("Can not find value `%s` in new parameters bound flag", value));
+ throw new MySQLProtocolException(String.format("Can not find value `%s` in new parameters bound flag", value));
}
}
diff --git a/shardingsphere-dialect-exception/shardingsphere-dialect-exception-core/src/main/java/org/apache/shardingsphere/dialect/exception/SQLDialectException.java b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/exception/MySQLProtocolException.java
similarity index 67%
copy from shardingsphere-dialect-exception/shardingsphere-dialect-exception-core/src/main/java/org/apache/shardingsphere/dialect/exception/SQLDialectException.java
copy to shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/exception/MySQLProtocolException.java
index 75d51603aa5..56539a5bf4e 100644
--- a/shardingsphere-dialect-exception/shardingsphere-dialect-exception-core/src/main/java/org/apache/shardingsphere/dialect/exception/SQLDialectException.java
+++ b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/exception/MySQLProtocolException.java
@@ -15,14 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.dialect.exception;
+package org.apache.shardingsphere.db.protocol.mysql.exception;
-import org.apache.shardingsphere.infra.util.exception.external.ShardingSphereExternalException;
+import org.apache.shardingsphere.dialect.exception.SQLDialectException;
/**
- * SQL dialect exception.
+ * MySQL protocol exception.
*/
-public abstract class SQLDialectException extends ShardingSphereExternalException {
+public final class MySQLProtocolException extends SQLDialectException {
- private static final long serialVersionUID = -5090068160364259336L;
+ private static final long serialVersionUID = -2955235917749217233L;
+
+ public MySQLProtocolException(final String reason) {
+ super(reason);
+ }
}
diff --git a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlagTest.java b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlagTest.java
index 7bae96baf3c..7befc87ae78 100644
--- a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlagTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlagTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.db.protocol.mysql.constant;
+import org.apache.shardingsphere.db.protocol.mysql.exception.MySQLProtocolException;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -29,7 +30,7 @@ public final class MySQLNewParametersBoundFlagTest {
assertThat(MySQLNewParametersBoundFlag.valueOf(MySQLNewParametersBoundFlag.PARAMETER_TYPE_EXIST.getValue()), is(MySQLNewParametersBoundFlag.PARAMETER_TYPE_EXIST));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = MySQLProtocolException.class)
public void assertValueOfWithIllegalArgument() {
MySQLNewParametersBoundFlag.valueOf(-1);
}
diff --git a/shardingsphere-dialect-exception/shardingsphere-dialect-exception-core/src/main/java/org/apache/shardingsphere/dialect/exception/SQLDialectException.java b/shardingsphere-dialect-exception/shardingsphere-dialect-exception-core/src/main/java/org/apache/shardingsphere/dialect/exception/SQLDialectException.java
index 75d51603aa5..2e5f203fe05 100644
--- a/shardingsphere-dialect-exception/shardingsphere-dialect-exception-core/src/main/java/org/apache/shardingsphere/dialect/exception/SQLDialectException.java
+++ b/shardingsphere-dialect-exception/shardingsphere-dialect-exception-core/src/main/java/org/apache/shardingsphere/dialect/exception/SQLDialectException.java
@@ -17,12 +17,18 @@
package org.apache.shardingsphere.dialect.exception;
+import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.util.exception.external.ShardingSphereExternalException;
/**
* SQL dialect exception.
*/
+@NoArgsConstructor
public abstract class SQLDialectException extends ShardingSphereExternalException {
private static final long serialVersionUID = -5090068160364259336L;
+
+ public SQLDialectException(final String reason) {
+ super(reason);
+ }
}