From 8482fa8de6bcc2e88116855eca8ae9718630fdfc Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sat, 30 Sep 2023 01:45:52 +0800 Subject: [PATCH] Refactor UnregisterStorageUnitBackendHandler --- .../rdl/storage/unit/UnregisterStorageUnitBackendHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/storage/unit/UnregisterStorageUnitBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/storage/unit/UnregisterStorageUnitBackendHandler.java index 80df2fc3e17dd0..f2da5e6dbaf8f9 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/storage/unit/UnregisterStorageUnitBackendHandler.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/storage/unit/UnregisterStorageUnitBackendHandler.java @@ -71,8 +71,8 @@ public void checkSQLStatement(final String databaseName, final UnregisterStorage } private void checkExisted(final String databaseName, final Collection storageUnitNames) { - Map storageUnits = ProxyContext.getInstance().getDatabase(databaseName).getResourceMetaData().getStorageUnitMetaData().getMetaDataMap(); - Collection notExistedStorageUnits = storageUnitNames.stream().filter(each -> !storageUnits.containsKey(each)).collect(Collectors.toList()); + Map metaDataMap = ProxyContext.getInstance().getDatabase(databaseName).getResourceMetaData().getStorageUnitMetaData().getMetaDataMap(); + Collection notExistedStorageUnits = storageUnitNames.stream().filter(each -> !metaDataMap.containsKey(each)).collect(Collectors.toList()); ShardingSpherePreconditions.checkState(notExistedStorageUnits.isEmpty(), () -> new MissingRequiredStorageUnitsException(databaseName, notExistedStorageUnits)); }