From bcadd0a515513481114454a35fd31606b8c87abe Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 26 Sep 2024 18:34:34 +0200 Subject: [PATCH] Fixes #12265 - Jetty 12.0.13 fails to start when the threadpool-all-virtual module is enabled. Added missing constructor and test case. Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/util/thread/VirtualThreadPool.java | 8 +++++++- .../jetty/tests/distribution/DistributionTests.java | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/VirtualThreadPool.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/VirtualThreadPool.java index d743dd6fdd2..5cd5f7b4f64 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/VirtualThreadPool.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/thread/VirtualThreadPool.java @@ -40,7 +40,7 @@ public class VirtualThreadPool extends ContainerLifeCycle implements ThreadPool, private final AutoLock.WithCondition _joinLock = new AutoLock.WithCondition(); private String _name; - private int _maxThreads = 200; + private int _maxThreads; private boolean _tracking; private boolean _detailedDump; private Thread _keepAlive; @@ -49,9 +49,15 @@ public class VirtualThreadPool extends ContainerLifeCycle implements ThreadPool, private volatile Semaphore _semaphore; public VirtualThreadPool() + { + this(200); + } + + public VirtualThreadPool(int maxThreads) { if (!VirtualThreads.areSupported()) throw new IllegalStateException("Virtual Threads not supported"); + _maxThreads = maxThreads; } /** diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java index 7af0af81469..5f57619d709 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java @@ -1540,9 +1540,10 @@ public class DistributionTests extends AbstractJettyHomeTest } } - @Test @DisabledForJreRange(max = JRE.JAVA_20) - public void testVirtualThreadPool() throws Exception + @ParameterizedTest + @ValueSource(strings = {"threadpool-virtual", "threadpool-all-virtual"}) + public void testVirtualThreadPool(String threadPoolModule) throws Exception { Path jettyBase = newTestJettyBaseDirectory(); String jettyVersion = System.getProperty("jettyVersion"); @@ -1551,7 +1552,7 @@ public class DistributionTests extends AbstractJettyHomeTest .jettyBase(jettyBase) .build(); - try (JettyHomeTester.Run run1 = distribution.start("--add-modules=threadpool-virtual,http")) + try (JettyHomeTester.Run run1 = distribution.start("--add-modules=http," + threadPoolModule)) { assertTrue(run1.awaitFor(START_TIMEOUT, TimeUnit.SECONDS)); assertEquals(0, run1.getExitValue());