Skip to content

CachedRandomPropertySourceAutoConfiguration fails to downcast RandomPropertySource when wrapped #757

@smaldini

Description

@smaldini

Libraries such as Jasypt and similar Metric wrappers might create delegate for each Environment.propertySource - In this case the down cast fails to resolve like this :

Caused by: java.lang.ClassCastException: Cannot cast com.ulisesbocchio.jasyptspringboot.wrapper.EncryptablePropertySourceWrapper to org.springframework.boot.env.RandomValuePropertySource
	at java.base/java.lang.Class.cast(Class.java:3605)
	at org.springframework.cloud.util.random.CachedRandomPropertySourceAutoConfiguration.initialize(CachedRandomPropertySourceAutoConfiguration.java:44)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...

Since that PropertySource relies on conventions around getProperty calls, we don't need the specific type to be passed.

Source:
https://github.com/spring-cloud/spring-cloud-commons/blob/master/spring-cloud-context/src/main/java/org/springframework/cloud/util/random/CachedRandomPropertySourceAutoConfiguration.java#L43

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions