Commit 62f85a6
committed
fix: release the JDK exchange when async dispatch wiring fails
JdkHttpTransport.executeAsync guards the whole post-adaptation dispatch
path so a synchronous throw becomes a failed future. But if sendAsync had
already returned a live in-flight exchange when a later step threw, that
exchange kept running on a future nothing would await, leaking its
connection.
Hoist the in-flight handle out of the try and cancel it from the catch so
the exchange is aborted on the failure path; the cancel is a no-op when
the throw happened at or before dispatch (handle still null).
Also document on the test's HttpClient double why its sslContext() and
send() stubs are inert: executeAsync only ever calls sendAsync, so neither
is reached on the path under test.1 parent 2b6be9c commit 62f85a6
2 files changed
Lines changed: 17 additions & 2 deletions
File tree
- sdk-transport-jdkhttp/src
- main/kotlin/org/dexpace/sdk/transport/jdkhttp
- test/kotlin/org/dexpace/sdk/transport/jdkhttp
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
141 | 145 | | |
142 | 146 | | |
143 | 147 | | |
| |||
148 | 152 | | |
149 | 153 | | |
150 | 154 | | |
151 | | - | |
| 155 | + | |
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
| |||
160 | 164 | | |
161 | 165 | | |
162 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
163 | 174 | | |
164 | 175 | | |
165 | 176 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
888 | 888 | | |
889 | 889 | | |
890 | 890 | | |
891 | | - | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
892 | 896 | | |
893 | 897 | | |
894 | 898 | | |
| |||
0 commit comments