spring-cloud / spring-cloud-openfeign

Support for using OpenFeign in Spring Cloud apps
Apache License 2.0
1.17k stars 756 forks source link

`FeignClientsRegistar` fails when trying to parse unresolved property placeholders in JDK 20+ #1023

Closed elkkhan closed 2 months ago

elkkhan commented 2 months ago

Spring Cloud version: 2023.0.1 (affects up to the latest version)

FeignClientsRegistar seems to purposefully ignore unresolved URLs that are SpEL but doesn't do so for property placeholders like ${placeholder}. For ignored SpEL strings, the input string is returned, but for placeholders, it tries to parse it into a URL object. Up until JDK 20, this would be OK and would not fail - and unresolved placeholder URL would probably fail somewhere later down the flow. This is because the underlying implementation of the URL class doesn't actually try to parse the host until unless the URL.openConnection() is called, which is not called in this method.

Since JDK 20, this behaviour has changed and the underlying implementation of the URL class now parses the host eagerly without waiting for a URL.openConnection() call.

This was discovered when our tests that use @JsonTest started failing once we upgraded to JDK 20+

spencergibb commented 2 months ago

Closing in favor of #1022, no need to open an issue and PR at the same time.