spring-cloud / spring-cloud/spring-cloud-netflix
HeartBeat request is not properly url encoded
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5k
- Forks
- 2.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 10
Description
Hi all,
Describe the bug
I am migrating an application that uses Jersey 1 to RestTemplate.
During migration I have encountered heart beat requests returning 400 Bad request status code and upon further debugging found out, that the sent request is not complete.
The application uses instanceId in format of service#version and that is the problem.
Using spring-cloud-netflix-eureka-client 3.1.2 I tested this scenario with both Jersey 1 and 2 passing.
Sample
I forked the repo and modified testcase AbstractEurekaHttpClientTest adding some characters that have to be escaped into instanceId.
testSendHeartBeat now failed for RestTemplate with 400 status code (as expected), however WebClient test still passed with 200 although logs showed 400 returned as well (no idea why, I did not proceed down the rabbit hole).
I replaced String concatenation in both WebClient and RestTemplate with UriBuilder and UriComponentsBuilder where deemed appropriate.
Feel free to check it out: https://github.com/NewAgeCZ/spring-cloud-netflix/commits/fix/urlencoding
Best regards!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with AbstractEurekaHttpClientTest and the heartbeat request construction in the RestTemplate and WebClient clients. Reproduce testSendHeartBeat using an instanceId containing service#version and compare the generated URLs; done means the request is properly encoded and the relevant tests pass without a 400 response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100