I have a controller with this endpoint
@GetMapping("/users/userid")
public ResponseEntity getUser(@PathVariable Long cardId){
Long userId = userService.getUserByCardId(cardId);
if(userId == null){
return new ResponseEntity(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(userId, HttpStatus.OK);
}
I call this endpoint with a restemplate
ResponseEntity<Long> responseEntity = restTemplate.exchange(url HttpMethod.GET, null, Long.class);
System.out.println(responseEntity.getStatusCodeValue());
I never see the system out.
When I debug, I see 404 is returned
exchange call return
org.springframework.web.client.HttpClientErrorExcepton$NotFound: 404 [no body]