From 447823316da54172b50d11396b1cbfb6bd432965 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Thu, 17 Dec 2020 14:16:42 +0100 Subject: [PATCH] backport fix for ArithmeticException --- jetty-util/src/main/java/org/eclipse/jetty/util/Pool.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Pool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Pool.java index 7fa2c441c98a..9a9752cad47e 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Pool.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Pool.java @@ -301,6 +301,11 @@ public Entry acquire() { LOGGER.ignore(e); size = entries.size(); + // Size can be 0 when the pool is in the middle of + // acquiring a connection while another thread + // removes the last one from the pool. + if (size == 0) + break; } index = (index + 1) % size; }