diff --git a/CHANGELOG.md b/CHANGELOG.md index eeca9ad641a..24daa32301b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ #### Bugs * Fix #6247: Support for proxy authentication from proxy URL user info * Fix #6342: UnmatchedFieldTypeModule prevents certain jackson features from working +* Fix #6354: Prevent deadlock in okhttp AsyncBody.cancel ### 6.13.3 (2024-08-13) diff --git a/httpclient-okhttp/src/main/java/io/fabric8/kubernetes/client/okhttp/OkHttpClientImpl.java b/httpclient-okhttp/src/main/java/io/fabric8/kubernetes/client/okhttp/OkHttpClientImpl.java index 81a88396fef..a267630893d 100644 --- a/httpclient-okhttp/src/main/java/io/fabric8/kubernetes/client/okhttp/OkHttpClientImpl.java +++ b/httpclient-okhttp/src/main/java/io/fabric8/kubernetes/client/okhttp/OkHttpClientImpl.java @@ -151,7 +151,10 @@ public CompletableFuture done() { @Override public void cancel() { - Utils.closeQuietly(source); + // closing from a non dispatcher thread risks deadlock because close is + // a long-running operation that may need to re-obtain the dispatcher lock + // and the thread may already be holding other locks + executor.execute(() -> Utils.closeQuietly(source)); done.cancel(false); } }