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 2023/02/06 13:48:44 UTC

[shardingsphere] branch master updated: Fix storage type NPE causing the proxy to fail to start with -f parameter (#24029)

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 f7602503fa6 Fix storage type NPE causing the proxy to fail to start with -f parameter (#24029)
f7602503fa6 is described below

commit f7602503fa62f527fd472ed184703091a5e0ec8b
Author: ZhangCheng <fl...@outlook.com>
AuthorDate: Mon Feb 6 21:48:31 2023 +0800

    Fix storage type NPE causing the proxy to fail to start with -f parameter (#24029)
---
 .../metadata/database/resource/ShardingSphereResourceMetaData.java  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceMetaData.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceMetaData.java
index 387dfb40842..ec355f3c7bd 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceMetaData.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/ShardingSphereResourceMetaData.java
@@ -55,10 +55,12 @@ public final class ShardingSphereResourceMetaData {
         dataSourceMetaDataMap = createDataSourceMetaDataMap(enabledDataSources, storageTypes);
     }
     
-    private Map<String, DatabaseType> createStorageTypes(final Map<String, DataSource> dataSources) {
+    private Map<String, DatabaseType> createStorageTypes(final Map<String, DataSource> enabledDataSources) {
         Map<String, DatabaseType> result = new LinkedHashMap<>(dataSources.size(), 1);
         for (Entry<String, DataSource> entry : dataSources.entrySet()) {
-            result.put(entry.getKey(), DatabaseTypeEngine.getStorageType(Collections.singletonList(entry.getValue())));
+            DatabaseType storageType = enabledDataSources.containsKey(entry.getKey()) ? DatabaseTypeEngine.getStorageType(Collections.singletonList(entry.getValue()))
+                    : DatabaseTypeEngine.getStorageType(Collections.emptyList());
+            result.put(entry.getKey(), storageType);
         }
         return result;
     }