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/11/30 10:03:23 UTC

[shardingsphere] branch master updated: Fix NPE of single data source table meta data refresh (#13868)

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 ce9964d  Fix NPE of single data source table meta data refresh (#13868)
ce9964d is described below

commit ce9964d6fbf5bbe5527774c783c96bcf293299b4
Author: Haoran Meng <me...@gmail.com>
AuthorDate: Tue Nov 30 18:02:30 2021 +0800

    Fix NPE of single data source table meta data refresh (#13868)
    
    Co-authored-by: shardingsphere <de...@shardingsphere.apache.org>
---
 .../infra/metadata/schema/builder/util/TableMetaDataUtil.java           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/util/TableMetaDataUtil.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/util/TableMetaDataUtil.java
index 429564a..e212ca1 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/util/TableMetaDataUtil.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/util/TableMetaDataUtil.java
@@ -59,7 +59,7 @@ public class TableMetaDataUtil {
     }
     
     private static void addOneActualTableDataNode(final SchemaBuilderMaterials materials, final Map<String, Collection<String>> dataSourceTableGroups, final DataNodes dataNodes, final String table) {
-        Optional<DataNode> optional = dataNodes.getDataNodes(table).stream().findFirst();
+        Optional<DataNode> optional = dataNodes.getDataNodes(table).stream().filter(dataNode -> materials.getDataSourceMap().keySet().contains(dataNode.getDataSourceName())).findFirst();
         String dataSourceName = optional.map(DataNode::getDataSourceName).orElse(materials.getDataSourceMap().keySet().iterator().next());
         String tableName = optional.map(DataNode::getTableName).orElse(table);
         addDataSourceTableGroups(dataSourceName, tableName, dataSourceTableGroups);