You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2021/01/04 10:45:11 UTC

[shardingsphere] branch master updated: Rename MySQLPasswordEncryptor to PasswordEncryption (#8882)

This is an automated email from the ASF dual-hosted git repository.

menghaoran 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 7c8b07c  Rename MySQLPasswordEncryptor to PasswordEncryption (#8882)
7c8b07c is described below

commit 7c8b07ca152175dfc1aee281a4d31ca31f7acccf
Author: 邱鹿 Lucas <lu...@163.com>
AuthorDate: Mon Jan 4 18:44:36 2021 +0800

    Rename MySQLPasswordEncryptor to PasswordEncryption (#8882)
    
    * Rename MySQLPasswordEncryptor to PasswordEncryptor
    
    * Rename PasswordEncryptor to PasswordEncryption
    
    * Rename PasswordEncryptor to PasswordEncryption
    
    Co-authored-by: qiulu3 <Lucas209910>
---
 .../shardingsphere/scaling/mysql/client/MySQLClient.java  |  3 ++-
 ...ySQLPasswordEncryptor.java => PasswordEncryption.java} |  4 ++--
 .../scaling/mysql/client/netty/MySQLNegotiateHandler.java | 15 +++++++--------
 ...swordEncryptorTest.java => PasswordEncryptorTest.java} |  4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/MySQLClient.java b/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/MySQLClient.java
index 2e1985f..1524328 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/MySQLClient.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/MySQLClient.java
@@ -44,6 +44,7 @@ import org.apache.shardingsphere.scaling.mysql.client.netty.MySQLCommandPacketDe
 import org.apache.shardingsphere.scaling.mysql.client.netty.MySQLNegotiateHandler;
 
 import java.net.InetSocketAddress;
+import java.util.Objects;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -112,7 +113,7 @@ public final class MySQLClient {
         responseCallback = new DefaultPromise<>(eventLoopGroup.next());
         MySQLComQueryPacket comQueryPacket = new MySQLComQueryPacket(queryString);
         channel.writeAndFlush(comQueryPacket);
-        return (int) waitExpectedResponse(MySQLOKPacket.class).getAffectedRows();
+        return (int) Objects.requireNonNull(waitExpectedResponse(MySQLOKPacket.class)).getAffectedRows();
     }
     
     /**
diff --git a/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/MySQLPasswordEncryptor.java b/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/PasswordEncryption.java
similarity index 97%
rename from shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/MySQLPasswordEncryptor.java
rename to shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/PasswordEncryption.java
index 8dbbbdd..9070deb 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/MySQLPasswordEncryptor.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/PasswordEncryption.java
@@ -24,10 +24,10 @@ import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
 /**
- * MySQL Password Encryptor.
+ * MySQL Password Encryption.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class MySQLPasswordEncryptor {
+public final class PasswordEncryption {
     
     /**
      * Encrypt password with MySQL protocol 41.
diff --git a/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/netty/MySQLNegotiateHandler.java b/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/netty/MySQLNegotiateHandler.java
index aab6f7b..641c1ef 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/netty/MySQLNegotiateHandler.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/main/java/org/apache/shardingsphere/scaling/mysql/client/netty/MySQLNegotiateHandler.java
@@ -17,22 +17,21 @@
 
 package org.apache.shardingsphere.scaling.mysql.client.netty;
 
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.concurrent.Promise;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
 import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLAuthenticationMethod;
 import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLCapabilityFlag;
 import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
 import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
 import org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLHandshakePacket;
 import org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLHandshakeResponse41Packet;
-import org.apache.shardingsphere.scaling.mysql.client.MySQLPasswordEncryptor;
+import org.apache.shardingsphere.scaling.mysql.client.PasswordEncryption;
 import org.apache.shardingsphere.scaling.mysql.client.ServerInfo;
 import org.apache.shardingsphere.scaling.mysql.client.ServerVersion;
 
-import lombok.RequiredArgsConstructor;
-import lombok.SneakyThrows;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.util.concurrent.Promise;
-
 import java.security.NoSuchAlgorithmException;
 
 /**
@@ -85,6 +84,6 @@ public final class MySQLNegotiateHandler extends ChannelInboundHandlerAdapter {
     
     @SneakyThrows(NoSuchAlgorithmException.class)
     private byte[] generateAuthResponse(final byte[] authPluginData) {
-        return (null == password || password.isEmpty()) ? new byte[0] : MySQLPasswordEncryptor.encryptWithMySQL41(password.getBytes(), authPluginData);
+        return (null == password || password.isEmpty()) ? new byte[0] : PasswordEncryption.encryptWithMySQL41(password.getBytes(), authPluginData);
     }
 }
diff --git a/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/client/MySQLPasswordEncryptorTest.java b/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/client/PasswordEncryptorTest.java
similarity index 90%
rename from shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/client/MySQLPasswordEncryptorTest.java
rename to shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/client/PasswordEncryptorTest.java
index e3f561b..1c28f93 100644
--- a/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/client/MySQLPasswordEncryptorTest.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/client/PasswordEncryptorTest.java
@@ -23,13 +23,13 @@ import java.security.NoSuchAlgorithmException;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
-public final class MySQLPasswordEncryptorTest {
+public final class PasswordEncryptorTest {
     
     @Test
     public void assertEncryptWithMySQL41() throws NoSuchAlgorithmException {
         byte[] passwordBytes = "password".getBytes();
         byte[] seed = getRandomSeed();
-        assertThat(MySQLPasswordEncryptor.encryptWithMySQL41(passwordBytes, seed), is(getExpectedPassword()));
+        assertThat(PasswordEncryption.encryptWithMySQL41(passwordBytes, seed), is(getExpectedPassword()));
     }
     
     private byte[] getRandomSeed() {