From 00fffb7ab0ec46c1a8ddfab7b48cdf8f26193a05 Mon Sep 17 00:00:00 2001 From: lwpro2 Date: Mon, 5 Apr 2021 16:41:19 +0800 Subject: [PATCH 1/2] Restore customization of PropertyResolver This commit reintroduces the ability to customize the PropertyResolver to use in PropertySourcesPropertyResolver See gh-26761 --- .../support/PropertySourcesPlaceholderConfigurer.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java index 293c4fa2f269..b1bc2bd8069f 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java +++ b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java @@ -170,10 +170,17 @@ public String getProperty(String key) { } } - processProperties(beanFactory, new PropertySourcesPropertyResolver(this.propertySources)); + processProperties(beanFactory, getPropertyResolver(this.propertySources)); this.appliedPropertySources = this.propertySources; } + /** + * Construct and provide a PropertyResolver from the given properties. + */ + public ConfigurablePropertyResolver getPropertyResolver(MutablePropertySources propertySources){ + return new PropertySourcesPropertyResolver(propertySources); + } + /** * Visit each bean definition in the given bean factory and attempt to replace ${...} property * placeholders with values from the given properties. From 2731d4f1002034abe7780336daf386435d133e59 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sat, 26 Aug 2023 10:11:25 +0200 Subject: [PATCH 2/2] Polish "Restore customization of PropertyResolver" See gh-26761 --- .../support/PropertySourcesPlaceholderConfigurer.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java index b1bc2bd8069f..1fd84402c121 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java +++ b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,14 +170,16 @@ public String getProperty(String key) { } } - processProperties(beanFactory, getPropertyResolver(this.propertySources)); + processProperties(beanFactory, createPropertyResolver(this.propertySources)); this.appliedPropertySources = this.propertySources; } /** - * Construct and provide a PropertyResolver from the given properties. + * Create a {@link ConfigurablePropertyResolver} for the specified property sources. + * @param propertySources the property sources to use + * @since 6.0.12 */ - public ConfigurablePropertyResolver getPropertyResolver(MutablePropertySources propertySources){ + protected ConfigurablePropertyResolver createPropertyResolver(MutablePropertySources propertySources){ return new PropertySourcesPropertyResolver(propertySources); }