Skip to content

MutablePropertySources will not find or remove proxied sources #25369

@philwebb

Description

@philwebb

MutablePropertySources has get and remove methods that look like this:

@Override
@Nullable
public PropertySource<?> get(String name) {
	int index = this.propertySourceList.indexOf(PropertySource.named(name));
	return (index != -1 ? this.propertySourceList.get(index) : null);
}

These attempt to find the index of a property source index by checking for the name. The PropertySource.named method returns a ComparisonPropertySource which depends on the inherited PropertySource equals and hashCode implementations.

The equals method looks like this:

	@Override
	public boolean equals(@Nullable Object other) {
		return (this == other || (other instanceof PropertySource &&
				ObjectUtils.nullSafeEquals(this.name, ((PropertySource<?>) other).name)));
	}

If you are using a library such as jasypt, it's possible that your property source will be a proxy instance and won't actually contain a populated name field. The equals method could use ((PropertySource<?>) other).getName())) which would solve this issue.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions