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

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 83980c36d3e4 CAMEL-25579: fix flaky HttpOAuth2TokenCachingTest under 
parallel builds (#27724)
83980c36d3e4 is described below

commit 83980c36d3e4a4925a7b18150e1fec0733d17ad3
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Mon Oct 12 19:24:54 2026 +0200

    CAMEL-25579: fix flaky HttpOAuth2TokenCachingTest under parallel builds 
(#27724)
    
    Co-authored-by: IBM Bob 2.2.1
---
 .../camel/component/http/HttpOAuth2CachedTokensKeyTest.java    | 10 +++++++++-
 .../camel/component/http/HttpOAuth2TokenCachingTest.java       | 10 +++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2CachedTokensKeyTest.java
 
b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2CachedTokensKeyTest.java
index 525f1f773020..cb1d30a1ea6c 100644
--- 
a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2CachedTokensKeyTest.java
+++ 
b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2CachedTokensKeyTest.java
@@ -27,6 +27,7 @@ import 
org.apache.camel.component.http.handler.HeaderValidationHandler;
 import org.apache.camel.component.http.handler.OAuth2TokenRequestHandler;
 import org.apache.hc.client5.http.HttpHostConnectException;
 import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.NoHttpResponseException;
 import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
 import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.Test;
@@ -36,6 +37,7 @@ import static 
org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * The options that decide which requests share a cached OAuth2 token 
(CAMEL-22080). The default ({@code HOST_ONLY}) and
@@ -158,7 +160,13 @@ public class HttpOAuth2CachedTokensKeyTest extends 
BaseHttpTest {
             oauth2Server.close();
             Exchange exchange = template.request(uri(localServer, 
oauth2Server, second, options), e -> {
             });
-            assertInstanceOf(HttpHostConnectException.class, 
exchange.getException());
+            // When the token endpoint server is closed, the HTTP client may 
report either
+            // HttpHostConnectException (connection refused) or 
NoHttpResponseException (mid-shutdown).
+            // Both indicate the token endpoint is unreachable, so accept 
either.
+            Exception ex = exchange.getException();
+            assertTrue(
+                    ex instanceof HttpHostConnectException || ex instanceof 
NoHttpResponseException,
+                    "Expected a connection-failure exception but got: " + 
ex.getClass().getName());
         }
     }
 
diff --git 
a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2TokenCachingTest.java
 
b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2TokenCachingTest.java
index 21bb9c68bbd0..9a5736caf96b 100644
--- 
a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2TokenCachingTest.java
+++ 
b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2TokenCachingTest.java
@@ -25,12 +25,14 @@ import 
org.apache.camel.component.http.handler.HeaderValidationHandler;
 import org.apache.camel.component.http.handler.OAuth2TokenRequestHandler;
 import org.apache.hc.client5.http.HttpHostConnectException;
 import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.NoHttpResponseException;
 import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
 import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class HttpOAuth2TokenCachingTest extends BaseHttpTest {
 
@@ -313,7 +315,13 @@ public class HttpOAuth2TokenCachingTest extends 
BaseHttpTest {
         assertNotNull(exchange);
         assertNotNull(exchange.getException());
         Exception exception = exchange.getException();
-        assertEquals(HttpHostConnectException.class, exception.getClass());
+        // When the token endpoint server is closed, the HTTP client may 
report either
+        // HttpHostConnectException (connection refused, port already 
released) or
+        // NoHttpResponseException (server closed the connection mid-flight 
during shutdown).
+        // Both indicate that the token endpoint is unreachable, so accept 
either.
+        assertTrue(
+                exception instanceof HttpHostConnectException || exception 
instanceof NoHttpResponseException,
+                "Expected a connection-failure exception but got: " + 
exception.getClass().getName());
     }
 
     protected void assertHeaders(Map<String, Object> headers) {

Reply via email to