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 2021/04/15 04:52:11 UTC

[shardingsphere] branch master updated: Remove unnecessary thread safe codes on PostgreSQLAuthenticationEngine (#10093)

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 c15c1fe  Remove unnecessary thread safe codes on PostgreSQLAuthenticationEngine (#10093)
c15c1fe is described below

commit c15c1fedb22a8906416b6a782709587340bb02bf
Author: Liang Zhang <te...@163.com>
AuthorDate: Thu Apr 15 12:51:31 2021 +0800

    Remove unnecessary thread safe codes on PostgreSQLAuthenticationEngine (#10093)
---
 .../authentication/PostgreSQLAuthenticationEngine.java         | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
index 33950dd..fd88d0b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
@@ -38,8 +38,6 @@ import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationRes
 import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationResultBuilder;
 import org.apache.shardingsphere.proxy.frontend.connection.ConnectionIdGenerator;
 
-import java.util.concurrent.atomic.AtomicBoolean;
-
 /**
  * Authentication engine for PostgreSQL.
  */
@@ -49,9 +47,9 @@ public final class PostgreSQLAuthenticationEngine implements AuthenticationEngin
     
     private static final int SSL_REQUEST_CODE = 80877103;
     
-    private final AtomicBoolean startupMessageReceived = new AtomicBoolean(false);
+    private boolean startupMessageReceived;
     
-    private volatile byte[] md5Salt;
+    private byte[] md5Salt;
     
     private AuthenticationResult currentAuthResult;
     
@@ -69,12 +67,12 @@ public final class PostgreSQLAuthenticationEngine implements AuthenticationEngin
             return AuthenticationResultBuilder.continued();
         }
         payload.getByteBuf().resetReaderIndex();
-        return startupMessageReceived.get() ? afterStartupMessage(context, (PostgreSQLPacketPayload) payload) : beforeStartupMessage(context, (PostgreSQLPacketPayload) payload);
+        return startupMessageReceived ? afterStartupMessage(context, (PostgreSQLPacketPayload) payload) : beforeStartupMessage(context, (PostgreSQLPacketPayload) payload);
     }
     
     private AuthenticationResult beforeStartupMessage(final ChannelHandlerContext context, final PostgreSQLPacketPayload payload) {
         PostgreSQLComStartupPacket comStartupPacket = new PostgreSQLComStartupPacket(payload);
-        startupMessageReceived.set(true);
+        startupMessageReceived = true;
         String database = comStartupPacket.getDatabase();
         if (!Strings.isNullOrEmpty(database) && !ProxyContext.getInstance().schemaExists(database)) {
             context.writeAndFlush(createErrorPacket(PostgreSQLErrorCode.INVALID_CATALOG_NAME, String.format("database \"%s\" does not exist", database)));