spring-cloud / spring-cloud/spring-cloud-commons

SimpleServcieInstance should override getScheme()

Open
#823 7 comments 0 reactions 1 assignee View on GitHub

@OlgaMaciaszek is already working on this.

Since Feb 22, 2022.

  • #926 by @dagerber — open
enhancement for-major-release help wanted
Dominant language
Java
Stars
751
Forks
744
Avg merge
1d 14h
Merged PRs (30d)
9

Description

I'm submitting a bugreport for

  • spring-cloud-commons
  • class org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties

Versions used:

  • spring-boot: 2.3.3
  • spring-cloud: Hoxton.SR7
  • spring-cloud-commons: 2.2.4.RELEASE

When using SimpleDiscoveryClient, non-HTTPS Urls do not work, they are always resolved as https:// URLs.
We are using https in production, but http in Tests to avoid the need to setup certificates for localhost.
There are workarounds, but I think this is a bug that should be fixed in spring-cloud-commons

e.g.

"spring.cloud.discovery.client.simple.instances.foo-service[0].uri= http://localhost:8889",
"spring.cloud.discovery.client.simple.instances.foo-service[0].secure = false",

foo-service is always resolved as https://localhost:8889, because SimpleServcieInstance (inner class of SimpleServiceProperties) does not override getScheme().

LoadBalancerUriTools calls getScheme() and in case of SimpleServiceInstance always receives null and thus always sets Scheme to https.

Proposed fix for org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties#SimpleServiceInstance

public String getScheme() { return this.isSecure() ? "https" : "http"; }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.