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 703bdeda497..e638fdaf713 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 @@ -140,13 +140,13 @@ public class Pool implements AutoCloseable, Dumpable * method called or be removed via {@link Pool.Entry#remove()} or * {@link Pool#remove(Pool.Entry)}. * - * @param maxReservations the max desired number of reserved entries, + * @param allotment the desired allotment, where each entry handles an allotment of maxMultiplex, * or a negative number to always trigger the reservation of a new entry. * @return a disabled entry that is contained in the pool, * or null if the pool is closed or if the pool already contains - * {@link #getMaxEntries()} entries. + * {@link #getMaxEntries()} entries, or the allotment has already been reserved */ - public Entry reserve(int maxReservations) + public Entry reserve(int allotment) { try (AutoLock l = lock.lock()) { @@ -159,9 +159,8 @@ public class Pool implements AutoCloseable, Dumpable // The pending count is an AtomicInteger that is only ever incremented here with // the lock held. Thus the pending count can be reduced immediately after the - // test below, but never incremented. Thus the maxReservations limit can be - // enforced. - if (maxReservations >= 0 && pending.get() >= maxReservations) + // test below, but never incremented. Thus the allotment limit can be enforced. + if (allotment >= 0 && (pending.get() * getMaxMultiplex()) >= allotment) return null; pending.incrementAndGet(); diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java index cd09de2517a..84bb102795f 100644 --- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java +++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java @@ -26,6 +26,7 @@ import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.util.FormRequestContent; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.util.Fields; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -70,6 +71,7 @@ public class DemoBaseTests extends AbstractDistributionTest } @Test + @Tag("external") public void testAsyncRest() throws Exception { String jettyVersion = System.getProperty("jettyVersion");