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 <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2024-09-26 18:34:34 +02:00
parent b371002594
commit bcadd0a515
2 changed files with 11 additions and 4 deletions

View File

@ -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;
}
/**

View File

@ -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());