Merged branch 'jetty-12.0.x' into 'jetty-12.1.x'.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2024-09-27 18:12:15 +02:00
commit 269af78a3a
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
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 final AutoLock.WithCondition _joinLock = new AutoLock.WithCondition();
private String _name; private String _name;
private int _maxThreads = 200; private int _maxThreads;
private boolean _tracking; private boolean _tracking;
private boolean _detailedDump; private boolean _detailedDump;
private Thread _keepAlive; private Thread _keepAlive;
@ -49,9 +49,15 @@ public class VirtualThreadPool extends ContainerLifeCycle implements ThreadPool,
private volatile Semaphore _semaphore; private volatile Semaphore _semaphore;
public VirtualThreadPool() public VirtualThreadPool()
{
this(200);
}
public VirtualThreadPool(int maxThreads)
{ {
if (!VirtualThreads.areSupported()) if (!VirtualThreads.areSupported())
throw new IllegalStateException("Virtual Threads not supported"); throw new IllegalStateException("Virtual Threads not supported");
_maxThreads = maxThreads;
} }
/** /**

View File

@ -1558,9 +1558,10 @@ public class DistributionTests extends AbstractJettyHomeTest
} }
} }
@Test
@DisabledForJreRange(max = JRE.JAVA_20) @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(); Path jettyBase = newTestJettyBaseDirectory();
String jettyVersion = System.getProperty("jettyVersion"); String jettyVersion = System.getProperty("jettyVersion");
@ -1569,7 +1570,7 @@ public class DistributionTests extends AbstractJettyHomeTest
.jettyBase(jettyBase) .jettyBase(jettyBase)
.build(); .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)); assertTrue(run1.awaitFor(START_TIMEOUT, TimeUnit.SECONDS));
assertEquals(0, run1.getExitValue()); assertEquals(0, run1.getExitValue());