You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2024/06/17 07:12:26 UTC

(shardingsphere) branch master updated: Remove useless grantee on DriverDatabaseConnectionManager's constructor (#31728)

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

zhangliang 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 ae3b0872b89 Remove useless grantee on DriverDatabaseConnectionManager's constructor (#31728)
ae3b0872b89 is described below

commit ae3b0872b89b835114c5689e7df75171fccf744f
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Jun 17 15:12:19 2024 +0800

    Remove useless grantee on DriverDatabaseConnectionManager's constructor (#31728)
---
 .../shardingsphere/infra/session/connection/ConnectionContext.java   | 4 ++++
 .../driver/jdbc/core/connection/DriverDatabaseConnectionManager.java | 5 ++---
 .../driver/jdbc/core/connection/ShardingSphereConnection.java        | 5 ++---
 .../jdbc/core/connection/DriverDatabaseConnectionManagerTest.java    | 3 +--
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/infra/session/src/main/java/org/apache/shardingsphere/infra/session/connection/ConnectionContext.java b/infra/session/src/main/java/org/apache/shardingsphere/infra/session/connection/ConnectionContext.java
index 36ee8b9c645..6197869704e 100644
--- a/infra/session/src/main/java/org/apache/shardingsphere/infra/session/connection/ConnectionContext.java
+++ b/infra/session/src/main/java/org/apache/shardingsphere/infra/session/connection/ConnectionContext.java
@@ -57,6 +57,10 @@ public final class ConnectionContext implements AutoCloseable {
         this(new Grantee("", ""));
     }
     
+    public ConnectionContext(final UsedDataSourceProvider usedDataSourceProvider) {
+        this(usedDataSourceProvider, new Grantee("", ""));
+    }
+    
     public ConnectionContext(final Grantee grantee) {
         this(Collections::emptySet, grantee);
     }
diff --git a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
index 680e15abea9..ae2a8a21789 100644
--- a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
+++ b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
@@ -35,7 +35,6 @@ import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData;
 import org.apache.shardingsphere.infra.instance.metadata.InstanceType;
 import org.apache.shardingsphere.infra.instance.metadata.proxy.ProxyInstanceMetaData;
 import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
-import org.apache.shardingsphere.infra.metadata.user.Grantee;
 import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
 import org.apache.shardingsphere.infra.session.connection.ConnectionContext;
 import org.apache.shardingsphere.infra.session.connection.transaction.TransactionConnectionContext;
@@ -84,10 +83,10 @@ public final class DriverDatabaseConnectionManager implements OnlineDatabaseConn
     
     private final ForceExecuteTemplate<Connection> forceExecuteTemplate = new ForceExecuteTemplate<>();
     
-    public DriverDatabaseConnectionManager(final String databaseName, final ContextManager contextManager, final Grantee grantee) {
+    public DriverDatabaseConnectionManager(final String databaseName, final ContextManager contextManager) {
         this.contextManager = contextManager;
         this.databaseName = databaseName;
-        connectionContext = new ConnectionContext(cachedConnections::keySet, grantee);
+        connectionContext = new ConnectionContext(cachedConnections::keySet);
         connectionContext.setCurrentDatabase(databaseName);
         physicalDataSourceMap = getPhysicalDataSourceMap(databaseName, contextManager);
         trafficDataSourceMap = getTrafficDataSourceMap(databaseName, contextManager);
diff --git a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
index cf302ac963d..a3e7259970a 100644
--- a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
+++ b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
@@ -82,9 +82,8 @@ public final class ShardingSphereConnection extends AbstractConnectionAdapter {
     public ShardingSphereConnection(final String databaseName, final ContextManager contextManager) {
         this.databaseName = databaseName;
         this.contextManager = contextManager;
-        Grantee grantee = new Grantee("", "");
-        databaseConnectionManager = new DriverDatabaseConnectionManager(databaseName, contextManager, grantee);
-        processId = processEngine.connect(grantee, databaseName);
+        databaseConnectionManager = new DriverDatabaseConnectionManager(databaseName, contextManager);
+        processId = processEngine.connect(new Grantee("", ""), databaseName);
     }
     
     /**
diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
index cd1d8f1f7ae..9391da3a394 100644
--- a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
+++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
@@ -27,7 +27,6 @@ import org.apache.shardingsphere.infra.instance.metadata.InstanceType;
 import org.apache.shardingsphere.infra.instance.metadata.proxy.ProxyInstanceMetaData;
 import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
 import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import org.apache.shardingsphere.infra.metadata.user.Grantee;
 import org.apache.shardingsphere.metadata.persist.MetaDataPersistService;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
@@ -71,7 +70,7 @@ class DriverDatabaseConnectionManagerTest {
     
     @BeforeEach
     void setUp() throws SQLException {
-        databaseConnectionManager = new DriverDatabaseConnectionManager(DefaultDatabase.LOGIC_NAME, mockContextManager(), new Grantee("", ""));
+        databaseConnectionManager = new DriverDatabaseConnectionManager(DefaultDatabase.LOGIC_NAME, mockContextManager());
     }
     
     private ContextManager mockContextManager() throws SQLException {