Repository navigation
Commit d7ca828
Ask the deadline before arming, not the holder
Review round two on the absolute deadline.
The check that refuses a hop with nothing left to spend was in
sendNextRequest, which only continuations pass through. A first attempt
goes straight to sendRequest, and under ROUND_ROBIN the up-front resolve
asks for no timeout at all, so a slow resolver could eat the whole
budget before any holder existed and a pooled hit would then arm at zero
and write anyway. The check has moved into scheduleRequestTimeout, which
every attempt passes through, first or otherwise, and which is the last
point before the request is written. It returns whether the attempt may
go ahead; the four call sites stop when it may not.
Asking the holder was the wrong question anyway: the first attempt has
no holder to ask. The budget is now a static on TimeoutsHolder, taken
off the future, which every caller has in hand before an attempt of its
own exists. Long.MAX_VALUE stands for an exchange that is not bounded as
a whole, so a per-attempt timeout needs no special case at the call
site. Resolving the configured timeout moved there with it, so the
constructor and the budget no longer resolve it separately.
Three comments described the change rather than the code, which
AGENTS.md asks us not to and which will not read well in a year: the two
on the fields Redirect30xInterceptor was dropping, and the one on
DefaultRequest's package-private constructor. The comment on
requestTimeoutMillisTime claimed isDeadlinePassed depended on it staying
negative; only startReadTimeout does. And the javadoc for the budget had
been left sitting on the test accessor by an earlier edit.
One test asserted nothing. isDeadlinePassed answered on its first
conjunct for a per-attempt exchange, so the arithmetic it was meant to
cover never ran. It asserts on the deadline the holder computes instead:
that a hop is handed the configured timeout of its own however long the
exchange has already run.
Carrying the read timeout across a redirect changes behaviour outside
this flag - a short per-request read timeout was reverting to the config
default on every hop after the first and now does not - and is called
out in the pull request for the release notes.
Claude Code on behalf of Pavel Ptashyts
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent fd9d2f3 commit d7ca828
6 files changed
Lines changed: 102 additions & 64 deletions
File tree
- client/src
- main/java/org/asynchttpclient
- netty
- handler/intercept
- request
- timeout
- test/java/org/asynchttpclient
- netty/timeout
Lines changed: 4 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
| |||
Lines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | 143 | | |
146 | 144 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
151 | 149 | | |
152 | 150 | | |
153 | 151 | | |
| |||
Lines changed: 41 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
| 416 | + | |
416 | 417 | | |
417 | | - | |
| 418 | + | |
418 | 419 | | |
419 | 420 | | |
420 | 421 | | |
| |||
525 | 526 | | |
526 | 527 | | |
527 | 528 | | |
528 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
529 | 532 | | |
530 | 533 | | |
531 | 534 | | |
| |||
595 | 598 | | |
596 | 599 | | |
597 | 600 | | |
598 | | - | |
599 | | - | |
| 601 | + | |
| 602 | + | |
600 | 603 | | |
601 | 604 | | |
602 | 605 | | |
603 | 606 | | |
604 | 607 | | |
605 | 608 | | |
606 | | - | |
607 | | - | |
| 609 | + | |
| 610 | + | |
608 | 611 | | |
609 | 612 | | |
610 | 613 | | |
| |||
1087 | 1090 | | |
1088 | 1091 | | |
1089 | 1092 | | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
1093 | 1096 | | |
1094 | 1097 | | |
1095 | 1098 | | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
1096 | 1106 | | |
1097 | 1107 | | |
1098 | 1108 | | |
1099 | 1109 | | |
| 1110 | + | |
1100 | 1111 | | |
1101 | | - | |
1102 | | - | |
1103 | | - | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
1104 | 1120 | | |
1105 | 1121 | | |
1106 | 1122 | | |
1107 | 1123 | | |
1108 | 1124 | | |
1109 | 1125 | | |
| 1126 | + | |
1110 | 1127 | | |
1111 | 1128 | | |
1112 | 1129 | | |
| |||
1216 | 1233 | | |
1217 | 1234 | | |
1218 | 1235 | | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
1226 | | - | |
1227 | 1236 | | |
1228 | 1237 | | |
1229 | 1238 | | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
1230 | 1249 | | |
1231 | 1250 | | |
1232 | 1251 | | |
1233 | 1252 | | |
1234 | 1253 | | |
1235 | | - | |
| 1254 | + | |
1236 | 1255 | | |
1237 | 1256 | | |
1238 | 1257 | | |
| |||
Lines changed: 34 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 85 | + | |
89 | 86 | | |
90 | 87 | | |
91 | 88 | | |
92 | 89 | | |
93 | 90 | | |
94 | 91 | | |
95 | 92 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
100 | 97 | | |
101 | 98 | | |
102 | 99 | | |
| |||
120 | 117 | | |
121 | 118 | | |
122 | 119 | | |
123 | | - | |
| 120 | + | |
| 121 | + | |
124 | 122 | | |
125 | 123 | | |
126 | 124 | | |
127 | 125 | | |
128 | | - | |
129 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
130 | 134 | | |
131 | 135 | | |
132 | 136 | | |
133 | | - | |
134 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
135 | 150 | | |
136 | 151 | | |
137 | 152 | | |
138 | | - | |
139 | | - | |
| 153 | + | |
140 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
141 | 160 | | |
142 | 161 | | |
143 | 162 | | |
144 | 163 | | |
145 | 164 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | 165 | | |
151 | 166 | | |
152 | 167 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
189 | | - | |
| 188 | + | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
Lines changed: 16 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
73 | 72 | | |
74 | 73 | | |
75 | 74 | | |
76 | | - | |
| 75 | + | |
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
81 | | - | |
82 | | - | |
| 80 | + | |
| 81 | + | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
90 | | - | |
91 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
92 | 96 | | |
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
99 | | - | |
100 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
101 | 108 | | |
102 | 109 | | |
103 | 110 | | |
| |||
0 commit comments