You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by to...@apache.org on 2022/04/10 09:19:21 UTC
[shardingsphere] branch master updated: Optimize code for JDBCBackendDataSource (#15876) (#16711)
This is an automated email from the ASF dual-hosted git repository.
totalo 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 cdd4627150b Optimize code for JDBCBackendDataSource (#15876) (#16711)
cdd4627150b is described below
commit cdd4627150b1a29ae21d3b2756d1eaadc25f41e8
Author: galaxy <ga...@tencent.com>
AuthorDate: Sun Apr 10 17:19:15 2022 +0800
Optimize code for JDBCBackendDataSource (#15876) (#16711)
---
.../infra/rule/builder/schema/SchemaRulesBuilder.java | 1 -
.../communication/jdbc/datasource/JDBCBackendDataSource.java | 6 +++---
.../yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/schema/SchemaRulesBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/schema/SchemaRulesBuilder.java
index 1862d9a1673..1abd81a928d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/schema/SchemaRulesBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/schema/SchemaRulesBuilder.java
@@ -70,7 +70,6 @@ public final class SchemaRulesBuilder {
DataSourceGeneratedSchemaConfiguration configuration = (DataSourceGeneratedSchemaConfiguration) schemaConfig;
checkDataSourceAggregations(configuration.getDataSourceProperties());
}
-
result.add(entry.getValue().build(entry.getKey(), schemaName, schemaConfig.getDataSources(), result, props));
}
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java
index 0c250f90c42..2eaa6eb636e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java
@@ -104,12 +104,12 @@ public final class JDBCBackendDataSource implements BackendDataSource {
= ProxyContext.getInstance().getContextManager().getTransactionContexts().getEngines().get(schemaName).getTransactionManager(transactionType);
boolean isDataSourceAggregation = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().getProps().containsKey("data-source-aggregation-enabled")
? ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().getValue(ConfigurationPropertyKey.DATA_SOURCE_AGGREGATION_ENABLED) : false;
- Connection connection = isInTransaction(transactionManager) ? transactionManager.getConnection(dataSourceName) : dataSource.getConnection();
+ Connection result = isInTransaction(transactionManager) ? transactionManager.getConnection(dataSourceName) : dataSource.getConnection();
if (isDataSourceAggregation) {
String databaseName = GlobalDataSourceRegistry.getInstance().getDataSourceSchema().get(schemaName + "." + dataSourceName);
- connection.setCatalog(databaseName);
+ result.setCatalog(databaseName);
}
- return connection;
+ return result;
}
private boolean isInTransaction(final ShardingSphereTransactionManager transactionManager) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
index 8325b81ca62..aa95e212b59 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/swapper/YamlProxyDataSourceConfigurationSwapper.java
@@ -35,7 +35,7 @@ public final class YamlProxyDataSourceConfigurationSwapper {
* @param yamlConfig YAML proxy data source configuration
* @param schemaName Schema name
* @param dataSourceName Data source name
- * @param isDataSourceAggregation Is data source aggregation
+ * @param isDataSourceAggregation is data source aggregation
* @return data source configuration
*/
public DataSourceConfiguration swap(final YamlProxyDataSourceConfiguration yamlConfig, final String schemaName, final String dataSourceName, final boolean isDataSourceAggregation) {