Commit c2d588d
authored
[Java][apache-httpclient] Apply connect timeout to requests, add read timeout support (#24284)
* fix(java/apache-httpclient): apply connect timeout to requests, add read timeout support
setConnectTimeout() stored the value in a field that was never read, so
the configured timeout was silently ignored and Apache HttpClient's own
defaults applied (3-minute connect timeout, unbounded response wait).
Wire connectionTimeout into a per-request RequestConfig set on the
HttpClientContext in invokeAPI(), and add symmetric getReadTimeout()/
setReadTimeout() support mapped to the response timeout. The per-request
approach works with both httpclient5 5.1.x (Gradle template) and 5.2.x
(Maven template) and preserves a user-supplied custom CloseableHttpClient
instead of rebuilding it.
Fixes #24269
* fix(java/apache-httpclient): preserve custom client request-config defaults, reject negative timeouts
Address review feedback:
- when building the per-request RequestConfig, start from the default
request configuration of the underlying HTTP client (via Configurable)
so a caller-supplied client's redirect policy, cookie spec and other
request defaults are preserved and only the configured timeouts are
overridden
- reject negative values in setConnectTimeout()/setReadTimeout() with
IllegalArgumentException instead of silently ignoring them
* test(java/apache-httpclient): close custom HTTP client in test via try-with-resources1 parent 80c08fa commit c2d588d
5 files changed
Lines changed: 330 additions & 24 deletions
File tree
- modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient
- samples/client
- echo_api/java/apache-httpclient/src/main/java/org/openapitools/client
- petstore/java
- apache-httpclient-jackson3/src/main/java/org/openapitools/client
- apache-httpclient/src
- main/java/org/openapitools/client
- test/java/org/openapitools/client
Lines changed: 59 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| 58 | + | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
| |||
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
| 141 | + | |
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
| |||
555 | 559 | | |
556 | 560 | | |
557 | 561 | | |
558 | | - | |
559 | | - | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
560 | 567 | | |
561 | 568 | | |
| 569 | + | |
562 | 570 | | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
567 | 606 | | |
568 | 607 | | |
569 | 608 | | |
| |||
1150 | 1189 | | |
1151 | 1190 | | |
1152 | 1191 | | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
1153 | 1206 | | |
1154 | 1207 | | |
1155 | 1208 | | |
| |||
Lines changed: 59 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| |||
430 | 434 | | |
431 | 435 | | |
432 | 436 | | |
433 | | - | |
434 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
435 | 442 | | |
436 | 443 | | |
| 444 | + | |
437 | 445 | | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
442 | 481 | | |
443 | 482 | | |
444 | 483 | | |
| |||
1016 | 1055 | | |
1017 | 1056 | | |
1018 | 1057 | | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
1019 | 1072 | | |
1020 | 1073 | | |
1021 | 1074 | | |
| |||
Lines changed: 59 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
| 148 | + | |
145 | 149 | | |
146 | 150 | | |
147 | 151 | | |
| |||
525 | 529 | | |
526 | 530 | | |
527 | 531 | | |
528 | | - | |
529 | | - | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
530 | 537 | | |
531 | 538 | | |
| 539 | + | |
532 | 540 | | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
537 | 576 | | |
538 | 577 | | |
539 | 578 | | |
| |||
1115 | 1154 | | |
1116 | 1155 | | |
1117 | 1156 | | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
1118 | 1171 | | |
1119 | 1172 | | |
1120 | 1173 | | |
| |||
0 commit comments