Skip to content

WebClientExchangeTags does not handle non-standard status codes #17695

Closed
@druppelt

Description

@druppelt

Currently when calling a service that returns non-standard status codes like 490 with the reactive webclient, the tagging for the metrics actuator will cause an exception.
I'm using version 2.1.5.RELEASE of spring-boot-starter-actuator and spring-boot-starter-webflux. If I find the time, I'll create a pull request. For which branch should I do that?

In case I don't find the time, here's what I found so far:
The issue is that HttpStatus is used instead of a raw int. org.springframework.boot.actuate.metrics.web.reactive.client.WebClientExchangeTags#status(ClientResponse) itself only needs the raw value, but calls response.statusCode() which calls HttpStatus.valueOf(getRawStatusCode()) which throws an IllegalArgumentException.
At this point the solution is easy, just use response.rawStatusCode().

But after that it fails in WebClientExchangeTags#outcome(ClientResponse), and here I'm not sure what an elegant solution would be. Either directly use the rawStatusCode and ditch the comfort of the HttpStatus enum, or add an option to create HttpStatus.UNKNOWN values with the rawStatusCode as constructor argument I guess. I prefer the latter solution, but it may have side effects, as the Enum is part of spring-web and thus used a lot (681 usages according to my IDE).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions