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

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2023-08-23 15:47:15 +02:00
commit 7f1d262aee
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
17 changed files with 186 additions and 30 deletions

View File

@ -32,14 +32,11 @@ This release process will produce releases:
+ [ ] Create and use branches `release/<ver>` to perform version specific release work from.
+ [ ] Ensure `VERSION.txt` additions for each release will be meaningful, descriptive, correct text.
+ [ ] Stage 9.4 release with Java 11.
+ [ ] Stage 10 release with Java 19.
+ [ ] Stage 11 release with Java 19.
+ [ ] Stage 10 release with Java 21.
+ [ ] Stage 11 release with Java 21.
+ [ ] Push release branches `release/<ver>` to to https://github.com/eclipse/jetty.project
+ [ ] Push release tags `jetty-<ver>` to https://github.com/eclipse/jetty.project
+ [ ] Edit a draft release (for each Jetty release) in GitHub (https://github.com/eclipse/jetty.project/releases). Content is generated with the "changelog tool".
Be mindful of the order you create multiple release drafts. The first one created will be the "oldest" when published. (eg: Draft is 9, then 10, then 11)
The last created "draft" will show up as "latest" in the github UI.
If you have to reroll, you'll have to delete the drafts and recreate them (especially so if 9 w/timestamp is in the mix of releases being worked on)
- [ ] Assign issue to "test manager", who will oversee the testing of the staged releases.
+ [ ] Test [CometD](https://github.com/cometd/cometd).
+ [ ] Test [Reactive HttpClient](https://github.com/jetty-project/jetty-reactive-httpclient).
@ -58,7 +55,7 @@ This release process will produce releases:
- [ ] Update Jetty versions on the website ( follow instructions in [jetty-website](https://github.com/eclipse/jetty-website/blob/master/README.md) ).
+ [ ] Update (or check) [Download](https://eclipse.dev/jetty/download.php) page is updated.
+ [ ] Update (or check) documentation page(s) are updated.
- [ ] Publish GitHub Releases in the order of oldest (eg: 9) to newest (eg: 11) (to ensure that "latest" in github is truly the latest)
- [ ] Publish GitHub Releases.
- [ ] Prepare release announcement for mailing lists.
- [ ] Publish any [security advisories](https://github.com/eclipse/jetty.project/security/advisories).
+ [ ] Edit `VERSION.txt` to include any actual CVE number next to correspondent issue.

View File

@ -93,8 +93,8 @@
<fail>false</fail>
<rules>
<requireJavaVersion>
<version>[19,)</version>
<message>[ERROR] OLD JDK [${java.version}] in use. Jetty documentation ${project.version} MUST use JDK 19 or newer</message>
<version>[21,)</version>
<message>[ERROR] OLD JDK [${java.version}] in use. Jetty documentation ${project.version} MUST use JDK 21 or newer</message>
</requireJavaVersion>
</rules>
</configuration>

View File

@ -14,7 +14,10 @@
[[og-module-threadpool-virtual-preview]]
===== Module `threadpool-virtual-preview`
The `threadpool-virtual-preview` module allows you to configure the server-wide thread pool, similarly to what you can do with the xref:og-module-threadpool[`threadpool`] Jetty module, but also specify to use virtual threads, introduced as a preview feature in Java 19.
The `threadpool-virtual-preview` module allows you to configure the server-wide thread pool, similarly to what you can do with the xref:og-module-threadpool[`threadpool`] Jetty module, but also specify to use virtual threads, introduced as a preview feature in Java 19 and in Java 20.
CAUTION: Only use this module if you are using Java 19 or Java 20.
If you are using Java 21 or later, use the xref:og-module-threadpool-virtual[`threadpool-virtual`] Jetty module instead.
NOTE: To enable preview features, this module needs to specify the `+--enable-preview+` command line option using the xref:og-modules-directive-exec[[exec\] directive], and as such it will fork another JVM.
@ -34,5 +37,5 @@ The name prefix to use for the virtual thread names.
`jetty.threadPool.virtual.allowSetThreadLocals`::
Whether virtual threads are allowed to set thread locals.
`jetty.threadPool.useVirtualThreads`::
`jetty.threadPool.virtual.inheritInheritableThreadLocals`::
Whether virtual threads inherit the values of `InheritableThreadLocal` variables.

View File

@ -0,0 +1,36 @@
//
// ========================================================================
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
[[og-module-threadpool-virtual]]
===== Module `threadpool-virtual`
The `threadpool-virtual` module allows you to configure the server-wide thread pool, similarly to what you can do with the xref:og-module-threadpool[`threadpool`] Jetty module, but also specify to use virtual threads, introduced as an official feature since Java 21.
CAUTION: Only use this module if you are using Java 21 or later.
If you are using Java 19 or Java 20, use the xref:og-module-threadpool-virtual-preview[`threadpool-virtual-preview`] Jetty module instead.
Refer to the xref:og-module-threadpool[`threadpool`] Jetty module for the general features provided by that Jetty module that also this Jetty module provides.
The module properties to configure the thread pool are:
----
include::{JETTY_HOME}/modules/threadpool-virtual.mod[tags=documentation]
----
The specific properties to configure virtual threads are:
`jetty.threadPool.virtual.namePrefix`::
The name prefix to use for the virtual thread names.
`jetty.threadPool.virtual.inheritInheritableThreadLocals`::
Whether virtual threads inherit the values of `InheritableThreadLocal` variables.

View File

@ -41,4 +41,9 @@ The time, in milliseconds, after which an idle thread is released from the pool
`jetty.threadPool.maxThreads`::
The max number of threads pooled by the thread pool -- defaults to 200.
If you want to use virtual threads, introduced as a preview feature in Java 19, use the xref:og-module-threadpool-virtual-preview[`threadpool-virtual-preview`] Jetty module instead (see also the xref:og-server-threadpool[section about configuring the thread pool]).
If you want to use virtual threads, introduced as a preview feature in Java 19 and Java 20, and become an official feature since Java 21, use the following modules:
* The xref:og-module-threadpool-virtual[`threadpool-virtual`] Jetty module for Java 21 or later.
* The xref:og-module-threadpool-virtual-preview[`threadpool-virtual-preview`] Jetty module for Java 19 and Java 20.
See also the xref:og-server-threadpool[section about configuring the thread pool].

View File

@ -34,6 +34,7 @@ include::module-ssl.adoc[]
include::module-ssl-reload.adoc[]
include::module-test-keystore.adoc[]
include::module-threadpool.adoc[]
include::module-threadpool-virtual.adoc[]
include::module-threadpool-virtual-preview.adoc[]
include::module-eeN-webapp.adoc[]
include::module-well-known.adoc[]

View File

@ -47,16 +47,18 @@ Now you can customize the `threadpool.ini` file to explicitly configure the thre
[[og-server-threadpool-virtual]]
===== Virtual Threads Support
Virtual threads have been introduced as a preview feature in Java 19.
Virtual threads have been introduced as a preview feature in Java 19 and Java 20, and have become an official feature since Java 21.
The xref:og-module-threadpool-virtual-preview[`threadpool-virtual-preview`] Jetty module provides support for virtual threads and it is mutually exclusive with the `threadpool` Jetty module.
The xref:og-module-threadpool-virtual-preview[`threadpool-virtual-preview`] Jetty module provides support for virtual threads in Java 19 and Java 20, and it is mutually exclusive with the `threadpool` Jetty module.
The xref:og-module-threadpool-virtual[`threadpool-virtual`] Jetty module provides support for virtual threads in Java 21 or later, and it is mutually exclusive with the `threadpool` Jetty module.
If you have already enabled the `threadpool` Jetty module, it is sufficient to remove it by removing the `$JETTY_BASE/start.d/threadpool.ini` file.
Then, you can enable the xref:og-module-threadpool-virtual-preview[`threadpool-virtual-preview`] module:
When using Java 21 or later, you can enable the xref:og-module-threadpool-virtual[`threadpool-virtual`] module:
----
$ java -jar $JETTY_HOME/start.jar --add-modules=threadpool-virtual-preview,http
$ java -jar $JETTY_HOME/start.jar --add-modules=threadpool-virtual,http
----
After the command above, the `$JETTY_BASE` directory looks like this:
@ -68,12 +70,12 @@ $JETTY_BASE
│ └── jetty-logging.properties
└── start.d
├── http.ini
└── threadpool-virtual-preview.ini
└── threadpool-virtual.ini
----
Now you can customize the `threadpool-virtual-preview.ini` file to explicitly configure the thread pool and the virtual threads and then start Jetty:
Now you can customize the `threadpool-virtual.ini` file to explicitly configure the thread pool and the virtual threads and then start Jetty:
[source,subs=quotes,options=nowrap]
----
include::jetty[setupArgs="--add-modules=threadpool-virtual-preview,http"]
include::jetty[setupArgs="--add-modules=threadpool-virtual,http"]
----

View File

@ -176,7 +176,7 @@ Jetty's xref:pg-arch-threads[threading architecture] requires a more sophisticat
Jetty's default thread pool implementation is link:{javadoc-url}/org/eclipse/jetty/util/thread/QueuedThreadPool.html[`QueuedThreadPool`].
`QueuedThreadPool` integrates with the xref:pg-arch-bean[Jetty component model], implements `Executor`, provides a `TryExecutor` implementation (discussed in the xref:pg-arch-threads-execution-strategy-adaptive[adaptive execution strategy section]), and supports xref:pg-arch-threads-thread-pool-virtual-threads[virtual threads] (introduced as a preview feature in Java 19).
`QueuedThreadPool` integrates with the xref:pg-arch-bean[Jetty component model], implements `Executor`, provides a `TryExecutor` implementation (discussed in the xref:pg-arch-threads-execution-strategy-adaptive[adaptive execution strategy section]), and supports xref:pg-arch-threads-thread-pool-virtual-threads[virtual threads] (introduced as a preview feature in Java 19 and Java 20, and as an official feature since Java 21).
`QueuedThreadPool` can be configured with a `maxThreads` value.
@ -203,9 +203,9 @@ A good balance between `QueuedThreadPool.idleTimeout` and `QueuedThreadPool.maxE
[[pg-arch-threads-thread-pool-virtual-threads]]
===== Virtual Threads
Virtual threads have been introduced in Java 19 as a preview feature.
Virtual threads have been introduced in Java 19 and Java 20 as a preview feature, and have become an official feature since Java 21.
NOTE: In Java versions where virtual threads are a preview feature, remember to add `+--enable-preview+` to the command line options to use virtual threads.
NOTE: In Java versions where virtual threads are a preview feature, remember to add `+--enable-preview+` to the JVM command line options to use virtual threads.
`QueuedThreadPool` can be configured to use virtual threads by specifying the virtual threads `Executor`:

View File

@ -0,0 +1,43 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<Configure>
<New id="threadPool" class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="name" property="jetty.threadPool.namePrefix" />
<Set name="minThreads" type="int"><Property name="jetty.threadPool.minThreads" deprecated="threads.min" default="10"/></Set>
<Set name="maxThreads" type="int"><Property name="jetty.threadPool.maxThreads" deprecated="threads.max" default="200"/></Set>
<Set name="reservedThreads" type="int"><Property name="jetty.threadPool.reservedThreads" default="-1"/></Set>
<Set name="idleTimeout" type="int"><Property name="jetty.threadPool.idleTimeout" deprecated="threads.timeout" default="60000"/></Set>
<Set name="maxEvictCount" type="int"><Property name="jetty.threadPool.maxEvictCount" default="1"/></Set>
<Set name="detailedDump" type="boolean"><Property name="jetty.threadPool.detailedDump" default="false"/></Set>
<Get id="namePrefix" name="name" />
<Call class="java.lang.Thread" name="ofVirtual">
<Call class="java.lang.Thread$Builder" name="name">
<Arg>
<Property name="jetty.threadPool.virtual.namePrefix">
<Default><Ref refid="namePrefix" />-virtual-</Default>
</Property>
</Arg>
<Arg type="long">0</Arg>
<Call class="java.lang.Thread$Builder" name="inheritInheritableThreadLocals">
<Arg type="boolean"><Property name="jetty.threadPool.virtual.inheritInheritableThreadLocals" default="false" /></Arg>
<Call id="virtualThreadFactory" class="java.lang.Thread$Builder" name="factory" />
</Call>
</Call>
</Call>
<Call name="setVirtualThreadsExecutor">
<Arg>
<Call class="java.util.concurrent.Executors" name="newThreadPerTaskExecutor">
<Arg><Ref refid="virtualThreadFactory" /></Arg>
</Call>
</Arg>
</Call>
</New>
<Call class="org.slf4j.LoggerFactory" name="getLogger">
<Arg>org.eclipse.jetty</Arg>
<Call name="info">
<Arg>Virtual threads are enabled.</Arg>
</Call>
</Call>
</Configure>

View File

@ -1,5 +1,5 @@
[description]
Enables and configures the Server ThreadPool with support for virtual threads.
Enables and configures the Server ThreadPool with support for virtual threads in Java 19 and Java 20.
[exec]
--enable-preview

View File

@ -0,0 +1,41 @@
[description]
Enables and configures the Server ThreadPool with support for virtual threads in Java 21 or later.
[depends]
logging
[provides]
threadpool
[xml]
etc/jetty-threadpool-virtual.xml
[ini-template]
# tag::documentation[]
## Platform threads name prefix.
#jetty.threadPool.namePrefix=qtp<hashCode>
## Minimum number of pooled threads.
#jetty.threadPool.minThreads=10
## Maximum number of pooled threads.
#jetty.threadPool.maxThreads=200
## Number of reserved threads (-1 for heuristic).
#jetty.threadPool.reservedThreads=-1
## Thread idle timeout (in milliseconds).
#jetty.threadPool.idleTimeout=60000
## The max number of idle threads that can be evicted in one idleTimeout period.
#jetty.threadPool.maxEvictCount=1
## Whether to output a detailed dump.
#jetty.threadPool.detailedDump=false
## Virtual threads name prefix.
#jetty.threadPool.virtual.namePrefix=qtp<hashCode>-virtual-
## Whether virtual threads inherits the values of inheritable thread locals.
#jetty.threadPool.virtual.inheritInheritableThreadLocals=true
# end::documentation[]

View File

@ -25,7 +25,7 @@ etc/jetty-threadpool.xml
#jetty.threadPool.reservedThreads=-1
## Whether to use virtual threads, if the runtime supports them.
## Deprecated, use Jetty module 'threadpool-virtual-preview' instead.
## Deprecated, use Jetty module 'threadpool-virtual' instead.
#jetty.threadPool.useVirtualThreads=false
## Thread idle timeout (in milliseconds).

View File

@ -73,7 +73,7 @@
<profile>
<id>enable-virtual-threads-preview</id>
<activation>
<jdk>[19,)</jdk>
<jdk>[19,21)</jdk>
</activation>
<build>
<plugins>

View File

@ -42,7 +42,7 @@
<profile>
<id>enable-preview</id>
<activation>
<jdk>[19,)</jdk>
<jdk>[19,21)</jdk>
</activation>
<build>
<plugins>

View File

@ -42,7 +42,7 @@
<profile>
<id>enable-preview</id>
<activation>
<jdk>[19,)</jdk>
<jdk>[19,21)</jdk>
</activation>
<build>
<plugins>

View File

@ -1984,8 +1984,8 @@
<configuration>
<rules>
<requireJavaVersion>
<version>[19,)</version>
<message>[ERROR] OLD JDK [${java.version}] in use. Jetty Release ${project.version} MUST use JDK 19 or newer</message>
<version>[21,)</version>
<message>[ERROR] OLD JDK [${java.version}] in use. Jetty Release ${project.version} MUST use JDK 21 or newer</message>
</requireJavaVersion>
</rules>
</configuration>

View File

@ -1444,7 +1444,35 @@ public class DistributionTests extends AbstractJettyHomeTest
@Test
@DisabledForJreRange(max = JRE.JAVA_18)
@Tag("flaky")
public void testVirtualThreadPoolPreview() throws Exception
{
String jettyVersion = System.getProperty("jettyVersion");
JettyHomeTester distribution = JettyHomeTester.Builder.newInstance()
.jettyVersion(jettyVersion)
.mavenLocalRepository(System.getProperty("mavenRepoPath"))
.build();
try (JettyHomeTester.Run run1 = distribution.start("--add-modules=threadpool-virtual-preview,http"))
{
assertTrue(run1.awaitFor(10, TimeUnit.SECONDS));
assertEquals(0, run1.getExitValue());
int httpPort = distribution.freePort();
try (JettyHomeTester.Run run2 = distribution.start(List.of("jetty.http.selectors=1", "jetty.http.port=" + httpPort)))
{
assertTrue(run2.awaitConsoleLogsFor("Started Server@", 10, TimeUnit.SECONDS));
startHttpClient();
ContentResponse response = client.newRequest("localhost", httpPort)
.timeout(15, TimeUnit.SECONDS)
.send();
assertEquals(HttpStatus.NOT_FOUND_404, response.getStatus());
}
}
}
@Test
@DisabledForJreRange(max = JRE.JAVA_20)
public void testVirtualThreadPool() throws Exception
{
Path jettyBase = newTestJettyBaseDirectory();
@ -1455,7 +1483,7 @@ public class DistributionTests extends AbstractJettyHomeTest
.mavenLocalRepository(System.getProperty("mavenRepoPath"))
.build();
try (JettyHomeTester.Run run1 = distribution.start("--add-modules=threadpool-virtual-preview,http"))
try (JettyHomeTester.Run run1 = distribution.start("--add-modules=threadpool-virtual,http"))
{
assertTrue(run1.awaitFor(START_TIMEOUT, TimeUnit.SECONDS));
assertEquals(0, run1.getExitValue());