spring-cloud/spring-cloud-netflix

HeartBeat request is not properly url encoded

Aberta

#4.121 aberto em 29 de set. de 2022

 (3 comentários) (0 reação) (0 responsável)Java (2.433 forks)batch import
bughelp wanted

Métricas do repositório

Stars
 (4.805 estrelas)
Métricas de merge de PR
 (Mesclagem média 3h 47m) (5 fundiu PRs em 30d)

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!

Guia do colaborador