This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/main by this push:
new 2ef38ff211 Adapt
AXRS20ClientServerBookTest::testGetGenericBookManyClientsInParallel to JDK-27
HttpClient changes (that use virtual threads for selectors by default) (#2783)
2ef38ff211 is described below
commit 2ef38ff211b391e4faeb49365f6d0b3c50d3a61e
Author: Andriy Redko <[email protected]>
AuthorDate: Mon Dec 15 08:39:06 2025 -0500
Adapt AXRS20ClientServerBookTest::testGetGenericBookManyClientsInParallel
to JDK-27 HttpClient changes (that use virtual threads for selectors by
default) (#2783)
---
.../systest/jaxrs/JAXRS20ClientServerBookTest.java | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
index 05bd9bc754..a6601a462e 100644
---
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
+++
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
@@ -160,7 +160,7 @@ public class JAXRS20ClientServerBookTest extends
AbstractBusClientServerTestBase
final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
final AtomicLong httpClientThreads = new AtomicLong();
- final Supplier<Long> captureHttpClientThreads = () ->
+ final Supplier<Long> captureHttpClientSelectorThreads = () ->
Arrays
.stream(threadMXBean.getAllThreadIds())
.mapToObj(id -> threadMXBean.getThreadInfo(id))
@@ -169,8 +169,16 @@ public class JAXRS20ClientServerBookTest extends
AbstractBusClientServerTestBase
.filter(t -> t.getThreadName().endsWith("-SelectorManager"))
.count();
+ final Supplier<Long> captureHttpClientThreads = () ->
+ Arrays
+ .stream(threadMXBean.getAllThreadIds())
+ .mapToObj(id -> threadMXBean.getThreadInfo(id))
+ .filter(Objects::nonNull)
+ .filter(t -> t.getThreadName().startsWith("HttpClient-"))
+ .count();
+
// Capture the number of client threads at start
- final long expectedHttpClientThreads = captureHttpClientThreads.get();
+ final long expectedHttpClientSelectorThreads =
captureHttpClientSelectorThreads.get();
final Collection<WebClient> clients = new ArrayList<>();
try {
final String target = "http://localhost:" + PORT +
"/bookstore/genericbooks/123";
@@ -195,7 +203,12 @@ public class JAXRS20ClientServerBookTest extends
AbstractBusClientServerTestBase
} finally {
pool.shutdown();
assertThat(pool.awaitTermination(1, TimeUnit.MINUTES), is(true));
- assertThat(captureHttpClientThreads.get(), greaterThan(0L));
+ // Since JDK-27, HttpClient selector thread is a virtual thread by
default
+ if (Runtime.version().feature() >= 27) {
+ assertThat(captureHttpClientSelectorThreads.get(),
equalTo(0L));
+ } else {
+ assertThat(captureHttpClientSelectorThreads.get(),
greaterThan(0L));
+ }
assertThat(httpClientThreads.get(), greaterThan(0L));
assertThat(httpClientThreads.get(), lessThan(150L)); /* a bit
higher that pool size */
}
@@ -204,7 +217,7 @@ public class JAXRS20ClientServerBookTest extends
AbstractBusClientServerTestBase
// Since JDK-21, HttpClient Implements AutoCloseable
if (Runtime.version().feature() >= 21) {
- assertThat(captureHttpClientThreads.get(),
lessThanOrEqualTo(expectedHttpClientThreads));
+ assertThat(captureHttpClientSelectorThreads.get(),
lessThanOrEqualTo(expectedHttpClientSelectorThreads));
}
}