From 9d21e57e73545ba445f2f946465bfdef66b8bb24 Mon Sep 17 00:00:00 2001 From: zhaojinchao Date: Tue, 16 Jan 2024 17:52:36 +0800 Subject: [PATCH] Refactor RuleItemChangedSubscriber ignore database name case avoid npe (#29739) --- .../mode/subsciber/RuleItemChangedSubscriber.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java index c7213221f3071..7d52720f764e0 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/subsciber/RuleItemChangedSubscriber.java @@ -51,7 +51,7 @@ public void renew(final AlterRuleItemEvent event) { RuleItemConfigurationChangedProcessor processor = TypedSPILoader.getService(RuleItemConfigurationChangedProcessor.class, event.getType()); String yamlContent = contextManager.getMetaDataContexts().getPersistService().getMetaDataVersionPersistService().getVersionPathByActiveVersion(event.getActiveVersionKey(), event.getActiveVersion()); - ShardingSphereDatabase database = contextManager.getMetaDataContexts().getMetaData().getDatabases().get(event.getDatabaseName()); + ShardingSphereDatabase database = contextManager.getMetaDataContexts().getMetaData().getDatabase(event.getDatabaseName()); RuleConfiguration currentRuleConfig = processor.findRuleConfiguration(database); synchronized (this) { processor.changeRuleItemConfiguration(event, currentRuleConfig, processor.swapRuleItemConfiguration(event, yamlContent)); @@ -71,7 +71,7 @@ public void renew(final DropRuleItemEvent event) { return; } RuleItemConfigurationChangedProcessor processor = TypedSPILoader.getService(RuleItemConfigurationChangedProcessor.class, event.getType()); - ShardingSphereDatabase database = contextManager.getMetaDataContexts().getMetaData().getDatabases().get(event.getDatabaseName()); + ShardingSphereDatabase database = contextManager.getMetaDataContexts().getMetaData().getDatabase(event.getDatabaseName()); RuleConfiguration currentRuleConfig = processor.findRuleConfiguration(database); synchronized (this) { processor.dropRuleItemConfiguration(event, currentRuleConfig);