Commit 61e2df7
committed
fix: keep single-close guard honest when delegate close() throws
LoggableResponseBody.closeDelegateOnce() set the delegateClosed flag only
after delegate.close() returned normally. When that close throws, the flag
was left false, so a second close() reaching the delegate through the other
entry point (the over-cap one-shot PrefixThenTailSource.close() vs the
wrapper's own close()) would close the delegate a second time. The guard
exists precisely to guarantee a single close for delegates whose handles are
not safe to close twice, and the error path silently broke that guarantee.
Flip the guard in a finally so the delegate is marked closed whether or not
its close() succeeds, while still letting the exception propagate. This also
matches the drain-path error handler, which already marks the delegate closed
after a failed source close so a later close() is a no-op.
Closes #1151 parent 80dfbf1 commit 61e2df7
2 files changed
Lines changed: 43 additions & 1 deletion
File tree
- sdk-core/src
- main/kotlin/org/dexpace/sdk/core/http/response
- test/kotlin/org/dexpace/sdk/core/http/response
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
214 | 219 | | |
| 220 | + | |
215 | 221 | | |
216 | 222 | | |
217 | 223 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
477 | 513 | | |
478 | 514 | | |
479 | 515 | | |
| |||
0 commit comments