From 9b51bb82e6b440bc6bd25eda14b80ab6d6a926fa Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sun, 3 Nov 2024 23:35:40 +0800 Subject: [PATCH] Add ShadowDataSourceMappingsFinder --- .../shadow/route/engine/ShadowRouteEngine.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteEngine.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteEngine.java index 518e9a506e9d4..8630312097e4a 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteEngine.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteEngine.java @@ -47,12 +47,12 @@ public void route(RouteContext routeContext, ShadowRule rule, ShadowDataSourceMa for (RouteUnit each : routeContext.getRouteUnits()) { String logicName = each.getDataSourceMapper().getLogicName(); String actualName = each.getDataSourceMapper().getActualName(); - Optional sourceDataSourceName = rule.findProductionDataSourceName(actualName); - if (sourceDataSourceName.isPresent()) { - String shadowDataSourceName = shadowDataSourceMappings.get(sourceDataSourceName.get()); + Optional productionDataSourceName = rule.findProductionDataSourceName(actualName); + if (productionDataSourceName.isPresent()) { + String shadowDataSourceName = shadowDataSourceMappings.get(productionDataSourceName.get()); toBeRemovedRouteUnit.add(each); toBeAddedRouteUnit.add(null == shadowDataSourceName - ? new RouteUnit(new RouteMapper(logicName, sourceDataSourceName.get()), each.getTableMappers()) + ? new RouteUnit(new RouteMapper(logicName, productionDataSourceName.get()), each.getTableMappers()) : new RouteUnit(new RouteMapper(logicName, shadowDataSourceName), each.getTableMappers())); } }