spring-projects / spring-projects/spring-boot

HTTP Service interface settings for WebClient are silently ignored

Open
#49,279 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: team-only type: bug
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

read-timeout config option is ignored for WEB_CLIENT client type
springboot-version: 4.0.2
java-version: 25

TestController - a mock remote server, sleeping for 10 seconds to simulate slow response

@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping
    public String test() throws InterruptedException {
        Thread.sleep(10000);
        return "Hello after 10 seconds";
    }
}

TestClient - http service client calling the mock server defined above

@HttpExchange("/test")
public interface TestClient {

    @GetExchange
    String test();
}

HttpServiceClientsConfiguration - importing TestClient with given group name + client type set to WEB_CLIENT

@Configuration
@ImportHttpServices(group = "test-group-name", types = TestClient.class, clientType = HttpServiceGroup.ClientType.WEB_CLIENT)
class HttpServiceClientsConfig {

}

Application - demo app simulating the request to the mock server

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    ApplicationRunner applicationRunner(TestClient testClient) {
        return _ -> {
            System.out.println("Calling test client...");
            String result = testClient.test();
            System.out.println("Result: " + result);
        };
    }
}

application.yaml

spring:
  http:
    serviceclient:
      test-group-name:
        base-url: http://localhost:8080
        read-timeout: 5s

the read timeout is set to 5 seconds while the slow response of mock server takes 10 seconds. I'd expect some kind of exception on mock server request execution but the request is processed after 10 seconds without any exception.

I tried it with REST_CLIENT client type, I got an ResourceAccessException after 5 seconds which is a desired behaviour.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the application.yaml configuration and reproduce the TestClient call using WEB_CLIENT, then compare it with the REST_CLIENT behavior described in the issue. Trace how the test-group-name read-timeout is applied to each client type. Done means a 10-second response triggers a timeout at about 5 seconds for WEB_CLIENT, as it does for REST_CLIENT.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.