Skip to content

Commit

Permalink
Fixes #12265 - Jetty 12.0.13 fails to start when the threadpool-all-v…
Browse files Browse the repository at this point in the history
…irtual module is enabled.

Added missing constructor and test case.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Sep 27, 2024
1 parent b371002 commit bcadd0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1540,9 +1540,10 @@ public void testVirtualThreadPoolPreview() throws Exception
}
}

@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");
Expand All @@ -1551,7 +1552,7 @@ public void testVirtualThreadPool() throws Exception
.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());
Expand Down

0 comments on commit bcadd0a

Please sign in to comment.