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 535a7a2d102 Refactor MySQLDateBinaryProtocolValue and 
MySQLTimeBinaryProtocolValue (#21252)
535a7a2d102 is described below

commit 535a7a2d102ab51591ac0220c09f272f868f5196
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Sep 28 22:36:37 2022 +0800

    Refactor MySQLDateBinaryProtocolValue and MySQLTimeBinaryProtocolValue 
(#21252)
---
 .../execute/protocol/MySQLDateBinaryProtocolValue.java       |  2 +-
 .../execute/protocol/MySQLTimeBinaryProtocolValue.java       |  6 ++++--
 .../execute/protocol/MySQLDateBinaryProtocolValueTest.java   |  2 +-
 .../execute/protocol/MySQLTimeBinaryProtocolValueTest.java   | 12 +++++++-----
 4 files changed, 13 insertions(+), 9 deletions(-)

diff --git 
a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
 
b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
index 8552592fb65..7a9a711743f 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
@@ -45,7 +45,7 @@ public final class MySQLDateBinaryProtocolValue implements 
MySQLBinaryProtocolVa
                 result.setNanos(payload.readInt4() * 1000);
                 return result;
             default:
-                throw new IllegalArgumentException(String.format("Wrong length 
`%d` of MYSQL_TYPE_TIME", length));
+                throw new SQLFeatureNotSupportedException(String.format("Wrong 
length `%d` of MYSQL_TYPE_TIME", length));
         }
     }
     
diff --git 
a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValue.java
 
b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValue.java
index 78e1e931c3c..70ea99ea3de 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValue.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValue.java
@@ -19,6 +19,8 @@ package 
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.
 
 import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
 
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.Calendar;
@@ -29,7 +31,7 @@ import java.util.Calendar;
 public final class MySQLTimeBinaryProtocolValue implements 
MySQLBinaryProtocolValue {
     
     @Override
-    public Object read(final MySQLPacketPayload payload) {
+    public Object read(final MySQLPacketPayload payload) throws SQLException {
         int length = payload.readInt1();
         payload.readInt1();
         payload.readInt4();
@@ -43,7 +45,7 @@ public final class MySQLTimeBinaryProtocolValue implements 
MySQLBinaryProtocolVa
                 result.setNanos(payload.readInt4());
                 return result;
             default:
-                throw new IllegalArgumentException(String.format("Wrong length 
`%d` of MYSQL_TYPE_DATE", length));
+                throw new SQLFeatureNotSupportedException(String.format("Wrong 
length `%d` of MYSQL_TYPE_DATE", length));
         }
     }
     
diff --git 
a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValueTest.java
 
b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValueTest.java
index e30e266019f..a0eecb586b2 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValueTest.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValueTest.java
@@ -86,7 +86,7 @@ public final class MySQLDateBinaryProtocolValueTest {
         assertThat(actualTimestamp.getNanos(), is(232323000));
     }
     
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = SQLFeatureNotSupportedException.class)
     public void assertReadWithIllegalArgument() throws SQLException {
         when(payload.readInt1()).thenReturn(100);
         new MySQLDateBinaryProtocolValue().read(payload);
diff --git 
a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValueTest.java
 
b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValueTest.java
index f9f48115b2a..41bd0af15eb 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValueTest.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-mysql-protocol/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValueTest.java
@@ -23,6 +23,8 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.Calendar;
@@ -41,12 +43,12 @@ public final class MySQLTimeBinaryProtocolValueTest {
     private MySQLPacketPayload payload;
     
     @Test
-    public void assertReadWithZeroByte() {
+    public void assertReadWithZeroByte() throws SQLException {
         assertThat(new MySQLTimeBinaryProtocolValue().read(payload), is(new 
Timestamp(0)));
     }
     
     @Test
-    public void assertReadWithEightBytes() {
+    public void assertReadWithEightBytes() throws SQLException {
         when(payload.readInt1()).thenReturn(8, 0, 10, 59, 0);
         Calendar actual = Calendar.getInstance();
         actual.setTimeInMillis(((Timestamp) new 
MySQLTimeBinaryProtocolValue().read(payload)).getTime());
@@ -56,7 +58,7 @@ public final class MySQLTimeBinaryProtocolValueTest {
     }
     
     @Test
-    public void assertReadWithTwelveBytes() {
+    public void assertReadWithTwelveBytes() throws SQLException {
         when(payload.readInt1()).thenReturn(12, 0, 10, 59, 0);
         Calendar actual = Calendar.getInstance();
         actual.setTimeInMillis(((Timestamp) new 
MySQLTimeBinaryProtocolValue().read(payload)).getTime());
@@ -65,8 +67,8 @@ public final class MySQLTimeBinaryProtocolValueTest {
         assertThat(actual.get(Calendar.SECOND), is(0));
     }
     
-    @Test(expected = IllegalArgumentException.class)
-    public void assertReadWithIllegalArgument() {
+    @Test(expected = SQLFeatureNotSupportedException.class)
+    public void assertReadWithIllegalArgument() throws SQLException {
         when(payload.readInt1()).thenReturn(100);
         new MySQLTimeBinaryProtocolValue().read(payload);
     }

Reply via email to