From 9e5d4c37160cb24269857e4c3e496108ad2c4dc6 Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Date: Wed, 8 Jan 2025 09:15:48 +0200 Subject: [PATCH] Do not proceed with the resource delivery if Borrower is cancelled (#265) Signed-off-by: Violeta Georgieva --- .../src/main/java/reactor/pool/SimpleDequePool.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reactor-pool/src/main/java/reactor/pool/SimpleDequePool.java b/reactor-pool/src/main/java/reactor/pool/SimpleDequePool.java index d66972e..84517d5 100644 --- a/reactor-pool/src/main/java/reactor/pool/SimpleDequePool.java +++ b/reactor-pool/src/main/java/reactor/pool/SimpleDequePool.java @@ -358,7 +358,7 @@ private void drainLoop() { continue; } Borrower borrower = pendingPoll(borrowers); - if (borrower == null) { + if (borrower == null || borrower.get()) { if (idleResourceLeastRecentlyUsed) { resources.offerFirst(slot); } @@ -367,6 +367,7 @@ private void drainLoop() { } incrementIdle(); //we expect to detect a disposed pool in the next round + //or the Borrower was cancelled continue; } if (isDisposed()) { @@ -413,8 +414,8 @@ private void drainLoop() { * ... and CAN ALLOCATE => Subscribe to allocator + Warmup * *=======================*/ Borrower borrower = pendingPoll(borrowers); - if (borrower == null) { - continue; //we expect to detect pool is shut down in next round + if (borrower == null || borrower.get()) { + continue; //we expect to detect pool is shut down in next round or the Borrower was cancelled } if (isDisposed()) { borrower.fail(new PoolShutdownException());