Skip to content

RestClient requestInterceptor not invoked after Spring Boot upgrade. #34743

Closed as not planned
@rpapeters

Description

@rpapeters

Since upgrading Spring Boot from 3.3.x to 3.4.x (spring-web from 6.1.x to 6.2.x) any registered request interceptors are not invoked.

For example we have this RestClient:

        final var restClient = RestClient.builder()
                .baseUrl(integralityUrl + "/api")
                .requestInterceptor((HttpRequest request, byte[] body, ClientHttpRequestExecution execution) -> {
                    System.out.println("THIS WILL NOT BE EXECUTED");
                    return execution.execute(request, body);
                })
                .build();

        restClient.get().uri("/some-endpoint").retrieve();

In this example the requestInterceptor is never invoked.

When looking into the code of spring-web 6.1.18 and 6.2.0 there is a difference in the retrieve function:

6.1.18

        public RestClient.ResponseSpec retrieve() {
            RestClient.ResponseSpec responseSpec = (RestClient.ResponseSpec)this.exchangeInternal((x$0, x$1) -> {
                return DefaultRestClient.this.new DefaultResponseSpec(x$0, x$1);
            }, false);
            Assert.state(responseSpec != null, "No ResponseSpec");
            return responseSpec;
        }

this.exchangeInternal will invoke createRequest which will invoke the interceptors.

6.2.0

        public RestClient.ResponseSpec retrieve() {
            return DefaultRestClient.this.new DefaultResponseSpec(this);
        }

this.exchangeInternal is not invoked.

Is this a bug or should it be configured differently?

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions