From d623bea71a542604bfb2a166c47fa603c04a6c90 Mon Sep 17 00:00:00 2001 From: weirhp Date: Mon, 4 Sep 2023 17:23:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3rdb=E4=B8=8B=E6=9C=89?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E9=85=8D=E5=88=B6=EF=BC=8C=E4=BC=9A=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E9=85=8D=E7=BD=AE=E7=9B=B8=E4=BA=92=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20(#4560)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 恩baseProperties这个变量是共享的,不能修改这个变量的属性值。要不后续的配置都会改变。关联issue为4355 --- .../otter/canal/client/adapter/support/YamlUtils.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/YamlUtils.java b/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/YamlUtils.java index b9d98f31..0c954104 100644 --- a/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/YamlUtils.java +++ b/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/YamlUtils.java @@ -73,6 +73,9 @@ public class YamlUtils { PropertySource propertySource = propertySources.get(0); Properties properties = new Properties(); + if (baseProperties != null) { + properties.putAll(baseProperties); + } properties.putAll((Map) propertySource.getSource()); @@ -82,12 +85,7 @@ public class YamlUtils { entry.setValue(((OriginTrackedValue) value).getValue()); } } - - if (baseProperties != null) { - baseProperties.putAll(properties); - properties = baseProperties; - } - + ConfigurationPropertySource sources = new MapConfigurationPropertySource(properties); Binder binder = new Binder(sources); return binder.bind(prefix, Bindable.of(clazz)).get();