From 91064171e2fa7f01c8536dff2076bdef2db9fcb6 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 25 Mar 2025 15:10:41 +0100 Subject: [PATCH] GH-3101 Make Binder an instance variable Resolves #3101 --- .../AbstractExtendedBindingProperties.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractExtendedBindingProperties.java b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractExtendedBindingProperties.java index c7762668c..0f9b899d0 100644 --- a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractExtendedBindingProperties.java +++ b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractExtendedBindingProperties.java @@ -61,6 +61,8 @@ public abstract class AbstractExtendedBindingProperties bindings) { this.bindings.putAll(bindings); } @@ -83,6 +85,10 @@ public abstract class AbstractExtendedBindingProperties sources = ConfigurationPropertySources.get(this.applicationContext.getEnvironment()); + PropertySourcesPlaceholdersResolver placeholdersResolver = new PropertySourcesPlaceholdersResolver(this.applicationContext.getEnvironment()); + this.propertiesBinder = new Binder(sources, placeholdersResolver, cs, null, null); } /* @@ -99,19 +105,13 @@ public abstract class AbstractExtendedBindingProperties sources = ConfigurationPropertySources.get(this.applicationContext.getEnvironment()); - PropertySourcesPlaceholdersResolver placeholdersResolver = new PropertySourcesPlaceholdersResolver(this.applicationContext.getEnvironment()); - Binder binder = new Binder(sources, placeholdersResolver, cs, null, null); - if (Jsr303Validator.isJsr303Present(this.applicationContext)) { Jsr303Validator validator = new Jsr303Validator(this.applicationContext); - binder.bind(this.getDefaultsPrefix(), + this.propertiesBinder.bind(this.getDefaultsPrefix(), Bindable.ofInstance(extendedBindingPropertiesTarget), new ValidationBindHandler(validator)); } else { - binder.bind(this.getDefaultsPrefix(), + this.propertiesBinder.bind(this.getDefaultsPrefix(), Bindable.ofInstance(extendedBindingPropertiesTarget)); } this.bindings.put(binding, extendedBindingPropertiesTarget);