This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch 4.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/4.1.x-fixes by this push:
     new 8db9dcc034d Fix the 4.1.x build: Client and WebClient are not 
AutoCloseable on this branch
8db9dcc034d is described below

commit 8db9dcc034d00322d8be1ec80c08d54535fd3140
Author: Freeman Fang <[email protected]>
AuthorDate: Fri Oct 30 22:17:21 2026 -0400

    Fix the 4.1.x build: Client and WebClient are not AutoCloseable on this 
branch
    
    Close the client of each failover strategy test iteration in a finally block
    instead of with try-with-resources, which does not compile on 4.1.x.
---
 .../cxf/systest/jaxrs/failover/AbstractFailoverTest.java   | 14 ++++++++++----
 .../cxf/systest/jaxrs/failover/LoadDistributorTest.java    |  5 +++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/AbstractFailoverTest.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/AbstractFailoverTest.java
index 79703625919..232c582f179 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/AbstractFailoverTest.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/AbstractFailoverTest.java
@@ -36,7 +36,6 @@ import org.apache.cxf.clustering.RandomStrategy;
 import org.apache.cxf.clustering.RetryStrategy;
 import org.apache.cxf.clustering.SequentialStrategy;
 import org.apache.cxf.endpoint.ConduitSelector;
-import org.apache.cxf.jaxrs.client.Client;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
@@ -242,8 +241,7 @@ public abstract class AbstractFailoverTest extends 
AbstractBusClientServerTestBa
                 feature.getTargetSelector().close();
                 bookStore = getBookStore(inactiveReplica, feature);
             }
-            // a single proxy is used by all iterations, so only a proxy of 
this iteration is closed
-            try (Client client = singleProxy ? null : 
WebClient.client(bookStore)) {
+            try {
                 verifyStrategy(bookStore, expectRandom
                                   ? RandomStrategy.class
                                   : SequentialStrategy.class);
@@ -282,6 +280,11 @@ public abstract class AbstractFailoverTest extends 
AbstractBusClientServerTestBa
                     randomized = true;
                 }
                 prevEndpoint = currEndpoint;
+            } finally {
+                // a single proxy is used by all iterations, so only a proxy 
of this iteration is closed
+                if (!singleProxy) {
+                    WebClient.client(bookStore).close();
+                }
             }
         }
         if (!singleProxy) {
@@ -301,7 +304,8 @@ public abstract class AbstractFailoverTest extends 
AbstractBusClientServerTestBa
         String prevEndpoint = null;
         for (int i = 0; i < 20; i++) {
             feature.getTargetSelector().close();
-            try (WebClient bookStore = getWebClient(inactiveReplica, feature)) 
{
+            WebClient bookStore = getWebClient(inactiveReplica, feature);
+            try {
                 verifyStrategy(bookStore, expectRandom
                                   ? RandomStrategy.class
                                   : SequentialStrategy.class);
@@ -334,6 +338,8 @@ public abstract class AbstractFailoverTest extends 
AbstractBusClientServerTestBa
                     randomized = true;
                 }
                 prevEndpoint = currEndpoint;
+            } finally {
+                bookStore.close();
             }
         }
         assertEquals("unexpected random/sequential distribution of failovers",
diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorTest.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorTest.java
index bcd94db0320..b175f2487ca 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorTest.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorTest.java
@@ -32,7 +32,6 @@ import 
org.apache.cxf.clustering.LoadDistributorTargetSelector;
 import org.apache.cxf.clustering.SequentialStrategy;
 import org.apache.cxf.endpoint.ConduitSelector;
 import org.apache.cxf.feature.AbstractFeature;
-import org.apache.cxf.jaxrs.client.Client;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
@@ -153,7 +152,7 @@ public class LoadDistributorTest extends 
AbstractBusClientServerTestBase {
         int address3Count = 0;
         for (int i = 0; i < 20; i++) {
             BookStore bookStore = getBookStore(initialAddress, feature);
-            try (Client client = WebClient.client(bookStore)) {
+            try {
                 verifyStrategy(bookStore, SequentialStrategy.class);
                 String bookId = "123";
 
@@ -167,6 +166,8 @@ public class LoadDistributorTest extends 
AbstractBusClientServerTestBase {
                 } else if (Server.ADDRESS3.equals(address)) {
                     address3Count++;
                 }
+            } finally {
+                WebClient.client(bookStore).close();
             }
         }
         assertEquals(10, address2Count);

Reply via email to