After upgrading my spring-boot application that uses Consul, I observe backward compatibility is broken. Spring boot upgraded from spring-boot:2.1.4.RELEASE
to spring-boot:jar:2.7.3
.
Earlier spring-cloud-consul used to work with bootstrap property "spring.cloud.consul.host" which contained value that included port also, eg: https://xyz:8610, now spring-cloud is forcing user to set additional property "spring.cloud.consul.port", if not forcefully appending consul default port, ending in invalid URI like https://<xyz.com>:8610:8500/v1/kv/abc/services
(spring-boot/spring-cloud) from
Spring-cloud-consul backward compatibility of property value parsing for "spring.cloud.consul.host" broken in spring-cloud-consul
version 3.1.1 in spring-boot application version spring-boot:jar:2.7.3
. It was working fine in older spring-cloud-consul-core:jar:2.1.1
As our application internally has addition custom usage in using host:port specified in one single property this is breaking upgrade.
Could someone confirm if spring-cloud is Mandating this change.
Error Details:
[ERROR] 2023-01-08 16:12:33,644 [main] org.springframework.boot.SpringApplication org.springframework.boot.SpringApplication Application run failed
org.springframework.cloud.consul.config.ConsulPropertySources$PropertySourceNotFoundException: com.ecwid.consul.transport.TransportException: org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: https://<xyz.com>:8610:8500/v1/kv/abc/services/xyz-service/?recurse&token=yyy-xxx
at org.springframework.cloud.consul.config.ConsulPropertySources.createPropertySource(ConsulPropertySources.java:143)
at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.locate(ConsulPropertySourceLocator.java:88)
at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:51)
at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.locateCollection(ConsulPropertySourceLocator.java:71)
at org.springframework.cloud.consul.config.ConsulPropertySourceLocator$$FastClassBySpringCGLIB$$b35ebf8.invoke(<generated>)
...
Caused by: com.ecwid.consul.transport.TransportException: org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: https://rn-spindlet-lapp21.rno.apple.com:8610:8500/v1/kv/rins/services/file-service,aluminum-prod-logging/?recurse&token=e23d8856-cfb3-2d2e-6fd2-e2ed3ab6f341
at com.ecwid.consul.transport.AbstractHttpTransport.executeRequest(AbstractHttpTransport.java:83)
at com.ecwid.consul.transport.AbstractHttpTransport.makeGetRequest(AbstractHttpTransport.java:36)
at com.ecwid.consul.v1.ConsulRawClient.makeGetRequest(ConsulRawClient.java:139)
at com.ecwid.consul.v1.ConsulRawClient.makeGetRequest(ConsulRawClient.java:128)
at com.ecwid.consul.v1.kv.KeyValueConsulClient.getKVValues(KeyValueConsulClient.java:147)
at com.ecwid.consul.v1.ConsulClient.getKVValues(ConsulClient.java:644)
My bootstrap:
spring:
cloud:
consul:
config:
format: YAML
data-key: local
enabled: true
prefix: abc/services
host: https://xyz:8610
token: xxx
tls:
keyStoreInstanceType: PKCS12
certificatePath: /abc/keystore
certificatePassword: rrr
keyStorePath: /abc/keystore
keyStorePassword: rrr
Actual result: ClientProtocolException: URI does not specify a valid host name: https://<xyz.com>:8610:8500/v1/kv/abc/services/
Expect: Spring cloud should initialize bootstrap currently as it was working fine in older spring-cloud-consul-core:jar:2.1.1
. This compatibility broken in higher spring-cloud-consul-core:jar:3.1.1
Most probably this is related to Config File Processing changes in Spring Boot 2.4.
As result
https://spring.io/blog/2020/12/22/spring-cloud-2020-0-0-aka-ilford-is-available
If you require the legacy bootstrap functionality add the
org.springframework.cloud:spring-cloud-starter-bootstrap
dependency to your project or migrate to new ConfigData API.