You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2026/10/11 19:44:34 UTC
(cxf) branch 4.1.x-fixes updated (5e6ce71edde -> 66e58c2b61e)
This is an automated email from the ASF dual-hosted git repository.
reta pushed a change to branch 4.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
from 5e6ce71edde CXF-7455 - Don't fail in HolderInInterceptor when a response omits an out part (#3562)
new c597a20077e Bump org.webjars:swagger-ui from 5.32.15 to 5.33.1 (#3559)
new 96ccb13dd00 Update ASM to 9.11
new 9c6072ea097 CXF-9257: Complete client futures if the async callback throws (#3565)
new 66e58c2b61e Recording .gitmergeinfo Changes
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.gitmergeinfo | 4 ++
.../java/org/apache/cxf/endpoint/ClientImpl.java | 6 +-
distribution/src/main/release/samples/pom.xml | 2 +-
parent/pom.xml | 4 +-
.../org/apache/cxf/jaxws/JaxwsClientCallback.java | 69 ++++++++++++----------
.../apache/cxf/jaxws/JaxwsClientCallbackTest.java | 53 +++++++++++++++++
.../cxf/jaxrs/client/JaxrsClientCallback.java | 31 ++++++++--
.../org/apache/cxf/jaxrs/client/WebClient.java | 15 ++++-
.../cxf/jaxrs/client/JaxrsClientCallbackTest.java | 69 ++++++++++++++++++++++
.../cxf/systest/jaxrs/JAXRSAsyncClientTest.java | 22 +++++++
10 files changed, 233 insertions(+), 42 deletions(-)
(cxf) 01/04: Bump org.webjars:swagger-ui from 5.32.15 to 5.33.1 (#3559)
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 4.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit c597a20077e5e56bd2e694886a41e1fc6fbe12e0
Author: dependabot[bot] <49...@users.noreply.github.com>
AuthorDate: Fri Oct 9 06:14:56 2026 -0400
Bump org.webjars:swagger-ui from 5.32.15 to 5.33.1 (#3559)
Bumps [org.webjars:swagger-ui](https://github.com/swagger-api/swagger-ui) from 5.32.15 to 5.33.1.
- [Release notes](https://github.com/swagger-api/swagger-ui/releases)
- [Commits](https://github.com/swagger-api/swagger-ui/compare/v5.32.15...v5.33.1)
---
updated-dependencies:
- dependency-name: org.webjars:swagger-ui
dependency-version: 5.33.1
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <su...@github.com>
Co-authored-by: dependabot[bot] <49...@users.noreply.github.com>
(cherry picked from commit 3ee6bbb8cbc1760e7e25be40e63e6a8fd2a8d1fb)
# Conflicts:
# distribution/src/main/release/samples/pom.xml
---
distribution/src/main/release/samples/pom.xml | 2 +-
parent/pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/distribution/src/main/release/samples/pom.xml b/distribution/src/main/release/samples/pom.xml
index 107be29f9de..ec083665b36 100644
--- a/distribution/src/main/release/samples/pom.xml
+++ b/distribution/src/main/release/samples/pom.xml
@@ -36,7 +36,7 @@
<cxf.jetty12.version>12.0.40</cxf.jetty12.version>
<cxf.netty.version>4.1.139.Final</cxf.netty.version>
<cxf.httpcomponents.client.version>4.5.14</cxf.httpcomponents.client.version>
- <cxf.swagger.ui.version>5.32.15</cxf.swagger.ui.version>
+ <cxf.swagger.ui.version>5.33.1</cxf.swagger.ui.version>
<cxf.tika.version>3.3.2</cxf.tika.version>
<cxf.tomcat.version>10.1.60</cxf.tomcat.version>
<cxf.jboss.weld.version>5.1.2.Final</cxf.jboss.weld.version>
diff --git a/parent/pom.xml b/parent/pom.xml
index 2148369afd8..36e72829a18 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -219,7 +219,7 @@
<cxf.spring.security.version>6.4.13</cxf.spring.security.version>
<cxf.spring.version>6.2.19</cxf.spring.version>
<cxf.stax-ex.version>1.8.3</cxf.stax-ex.version>
- <cxf.swagger.ui.version>5.32.15</cxf.swagger.ui.version>
+ <cxf.swagger.ui.version>5.33.1</cxf.swagger.ui.version>
<cxf.swagger.v3.version>2.2.55</cxf.swagger.v3.version>
<cxf.tika.version>3.3.2</cxf.tika.version>
<cxf.tomcat.version>10.1.60</cxf.tomcat.version>
(cxf) 04/04: Recording .gitmergeinfo Changes
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 4.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 66e58c2b61e682ab0fe6a4e2222d5ec1af2f9445
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sun Oct 11 15:42:27 2026 -0400
Recording .gitmergeinfo Changes
---
.gitmergeinfo | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.gitmergeinfo b/.gitmergeinfo
index 058b9ad5fa2..b3eb0db35ad 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -169,6 +169,7 @@ M 3db651449ead313e80a704937625a93bae782877
M 3dc267ab9fb98ba09ba7cb5f844a86aea31cfda6
M 3df960a32545b65207fd0b8f7ef38ca186c8cf93
M 3e602e82462a880a7ac0844806e880a49490ffdc
+M 3ee6bbb8cbc1760e7e25be40e63e6a8fd2a8d1fb
M 3f296bd4ea0ba4e46a1bfb3d1941e117e45d96f3
M 3fa2ffd04bc814d2fa9ab723d9b6c7f9fad35ed8
M 3fad621fb88f72769d2d66d1fef8fcf7f46fbc9f
@@ -235,6 +236,7 @@ M 5b95074df5c60b0faa57085acdfb192cacc1c877
M 5c1266b0e9815ec4bd02b4fb6ad4d534f01855b3
M 5c6e17ec3b9e65bbf1722cb42d0e9ce48038abdf
M 5ce2625d759ffd64224489448d200ae5bea7ec99
+M 5cf280ff008e17c3ef4b60927a79e83ae75a6643
M 5d3acd406d97ad57cd8a4334152e626131ecb15e
M 5d5595d9e62a46a1579b434bdccf913c75f8b0c0
M 5de63cbc5228a3b5809e26e1dbaf77eb2740ce93
@@ -391,6 +393,7 @@ M a7cf20570e443a8d54918dbcc17e45c229771871
M a7f2d373d9161a562fd553c542edc43a28e46817
M a837332ed37cae92e821ce17d7d95f24e55fd7a2
M a8b0e28ccf38d9ce85ebe80eebeadcff2b8e53df
+M a8ff134ae9302f538cea9eda9ebce6b902637d78
M a90163cc1e1b8958b9a6a511a15d7b2104669aad
M a93af5270bc77a0e153ef2fdee49b52b6895bb95
M a97d12d02cd74d9382a94e9ed56bc9ec92ed80ca
@@ -456,6 +459,7 @@ M c4ed00a94050af9170f0897b91166b94819fe145
M c5126622a8536074d93af31e3c544c950895a690
M c55bef4d1e3a6c82226534254213bdad8ebd6273
M c6968586c290a920aa3633b35da2dbb72bf2dea8
+M c6be0ba580008bab15a3f1103d73af12abe42b88
M c6c9b73769533a84ffdf8f51e904fe17845163d6
M c7c752099dc0562202cbd69e3e396d357ef2dd4e
M c7ebc48fba76b3979790722cc8a420673bfc4cf3
(cxf) 02/04: Update ASM to 9.11
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 4.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 96ccb13dd0058a1c312f410564be8b4b43208349
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Fri Oct 9 10:00:38 2026 -0400
Update ASM to 9.11
(cherry picked from commit 1c26767cc60aeaba2c265d31abd01f1897e5d6ea)
---
parent/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/parent/pom.xml b/parent/pom.xml
index 36e72829a18..7e5671bb919 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -58,7 +58,7 @@
<!-- stuff related to ASM -->
<cxf.asm.groupId>org.ow2.asm</cxf.asm.groupId>
<cxf.asm.artifactId>asm</cxf.asm.artifactId>
- <cxf.asm.version>9.10.1</cxf.asm.version>
+ <cxf.asm.version>9.11</cxf.asm.version>
<!-- OSGi related properties -->
<cxf.fragment.host />
(cxf) 03/04: CXF-9257: Complete client futures if the async callback throws (#3565)
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 4.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 9c6072ea097b4e68035c57620b053e35ae6991ba
Author: Markus Heiden <ma...@markusheiden.de>
AuthorDate: Sun Oct 11 20:00:00 2026 +0200
CXF-9257: Complete client futures if the async callback throws (#3565)
* Complete client futures if the async callback throws
JaxrsClientCallback and JaxwsClientCallback invoke the user's callback
before completing their future. If the callback throws, the exception
escapes and the future is never completed, so threads blocked in
Future.get() hang forever. In the JAX-WS case ClientImpl additionally
catches the exception and invokes the same callback a second time.
Guard every callback invocation:
- If the callback throws while handling a successful response, the
future completes exceptionally with that exception, like the JAX-WS
reference implementation does.
- If the callback throws while handling a failure, cancellation or
interruption, the original exception is kept and the callback's
exception is attached as a suppressed exception.
Co-Authored-By: Claude Fable 5.1 <no...@anthropic.com>
Claude-Session: https://claude.ai/code/session_0149ipFQyLFL9z5WdmhCRg3r
* Follow the callback contract instead of guarding handleResponse
CXF callers invoke ClientCallback.handleException() if handleResponse()
throws, so the callbacks don't need to guard the success path. Revert
those guards and fix the call sites that don't follow the contract:
ClientImpl's fault observer wrapper and WebClient's
ClientAsyncResponseInterceptor.
The failure paths stay guarded in the callbacks, because callers can't
complete the future if handleException() throws. Don't add a callback
exception as suppressed to itself, which would throw
IllegalArgumentException if the callback rethrows the exception it was
given.
Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ka6VjhpAcDrSERoiLP2Cxx
---------
Co-authored-by: Claude Fable 5.1 <no...@anthropic.com>
(cherry picked from commit cca9715fb00577b31a74a85f2fabbc8feff08bb5)
---
.../java/org/apache/cxf/endpoint/ClientImpl.java | 6 +-
.../org/apache/cxf/jaxws/JaxwsClientCallback.java | 69 ++++++++++++----------
.../apache/cxf/jaxws/JaxwsClientCallbackTest.java | 53 +++++++++++++++++
.../cxf/jaxrs/client/JaxrsClientCallback.java | 31 ++++++++--
.../org/apache/cxf/jaxrs/client/WebClient.java | 15 ++++-
.../cxf/jaxrs/client/JaxrsClientCallbackTest.java | 69 ++++++++++++++++++++++
.../cxf/systest/jaxrs/JAXRSAsyncClientTest.java | 22 +++++++
7 files changed, 226 insertions(+), 39 deletions(-)
diff --git a/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java b/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
index 17fdc79b400..35803e1c4f2 100644
--- a/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
+++ b/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
@@ -517,7 +517,11 @@ public class ClientImpl
Map<String, Object> ctx = responseContext.get(Thread.currentThread());
List<Object> resList = CastUtils.cast(inMsg.getContent(List.class));
Object[] result = resList == null ? null : resList.toArray();
- callback.handleResponse(ctx, result);
+ try {
+ callback.handleResponse(ctx, result);
+ } catch (Throwable t) {
+ callback.handleException(ctx, t);
+ }
return;
}
}
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsClientCallback.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsClientCallback.java
index c73da2d9f3f..bdae53f0214 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsClientCallback.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsClientCallback.java
@@ -86,41 +86,48 @@ class JaxwsClientCallback<T> extends ClientCallback {
public void handleException(Map<String, Object> ctx, final Throwable ex) {
context = ctx;
+ // The handler has to be called *before* future completes
if (handler != null) {
- handler.handleResponse(new Response<T>() {
- protected boolean cancelled;
-
- public Map<String, Object> getContext() {
- return context;
- }
-
- public boolean cancel(boolean mayInterruptIfRunning) {
- cancelled = true;
- return true;
- }
-
- public T get() throws InterruptedException, ExecutionException {
- throw new ExecutionException(ex);
+ try {
+ handler.handleResponse(new Response<T>() {
+ protected boolean cancelled;
+
+ public Map<String, Object> getContext() {
+ return context;
+ }
+
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ cancelled = true;
+ return true;
+ }
+
+ public T get() throws InterruptedException, ExecutionException {
+ throw new ExecutionException(ex);
+ }
+
+ public T get(long timeout, TimeUnit unit)
+ throws InterruptedException, ExecutionException, TimeoutException {
+
+ throw new ExecutionException(ex);
+ }
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public boolean isDone() {
+ return true;
+ }
+
+ });
+ } catch (Throwable t) {
+ // The future has to complete even if the handler fails, otherwise waiting threads hang forever
+ if (t != ex) {
+ ex.addSuppressed(t);
}
-
- public T get(long timeout, TimeUnit unit)
- throws InterruptedException, ExecutionException, TimeoutException {
-
- throw new ExecutionException(ex);
- }
-
- public boolean isCancelled() {
- return cancelled;
- }
-
- public boolean isDone() {
- return true;
- }
-
- });
+ }
}
- // The handler has to be called *before* future completes
delegate.completeExceptionally(mapThrowable(ex));
synchronized (this) {
diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxwsClientCallbackTest.java b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxwsClientCallbackTest.java
index 73380b40ceb..8bbfbe9c4b3 100644
--- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxwsClientCallbackTest.java
+++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxwsClientCallbackTest.java
@@ -37,6 +37,7 @@ import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertThrows;
@@ -151,6 +152,58 @@ public class JaxwsClientCallbackTest {
callback.get(10, TimeUnit.MILLISECONDS);
}
+ @Test
+ public void testHandleResponseCallbackThrows() throws Exception {
+ final RuntimeException handlerException = new RuntimeException("handler failed");
+ useThrowingHandler(handlerException);
+
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+ Object[] result = new Object[0];
+ // Callers invoke handleException() if handleResponse() throws
+ schedule(barrier, () -> {
+ try {
+ callback.handleResponse(ctx, result);
+ } catch (Throwable t) {
+ callback.handleException(ctx, t);
+ }
+ });
+ barrier.await(5, TimeUnit.SECONDS);
+
+ ExecutionException ex = assertThrows(ExecutionException.class, () -> callback.get(5, TimeUnit.SECONDS));
+ assertThat(ex.getCause(), sameInstance(handlerException));
+ assertThat(handlerException.getSuppressed().length, equalTo(0));
+ assertThrows(ExecutionException.class, () -> callback.get());
+ assertThat(callback.isCancelled(), equalTo(false));
+ assertThat(callback.isDone(), equalTo(true));
+ }
+
+ @Test
+ public void testHandleExceptionCallbackThrows() throws Exception {
+ final RuntimeException handlerException = new RuntimeException("handler failed");
+ useThrowingHandler(handlerException);
+
+ final RuntimeException cause = new RuntimeException("invocation failed");
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+ schedule(barrier, () -> callback.handleException(ctx, cause));
+ barrier.await(5, TimeUnit.SECONDS);
+
+ ExecutionException ex = assertThrows(ExecutionException.class, () -> callback.get(5, TimeUnit.SECONDS));
+ assertThat(ex.getCause(), sameInstance(cause));
+ assertThat(cause.getSuppressed(), equalTo(new Throwable[] {handlerException}));
+ assertThat(callback.isCancelled(), equalTo(false));
+ assertThat(callback.isDone(), equalTo(true));
+ }
+
+ private void useThrowingHandler(final RuntimeException handlerException) {
+ handler = new AsyncHandler<String>() {
+ @Override
+ public void handleResponse(Response<String> res) {
+ throw handlerException;
+ }
+ };
+ callback = new JaxwsClientCallback<String>(handler, null);
+ }
+
private void schedule(CyclicBarrier barrier, Runnable runnable) {
executor.schedule(() -> {
barrier.await(5, TimeUnit.SECONDS);
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JaxrsClientCallback.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JaxrsClientCallback.java
index 0532270a450..b1a590e299b 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JaxrsClientCallback.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JaxrsClientCallback.java
@@ -59,7 +59,11 @@ public class JaxrsClientCallback<T> extends ClientCallback {
if (!started) {
// The handler has to be called *before* future completes
if (handler != null) {
- handler.failed(new CancellationException());
+ try {
+ handler.failed(new CancellationException());
+ } catch (Throwable t) {
+ // The future has to be cancelled even if the handler fails
+ }
}
delegate.cancel(mayInterruptIfRunning);
@@ -98,7 +102,14 @@ public class JaxrsClientCallback<T> extends ClientCallback {
// The handler has to be called *before* future completes
if (handler != null) {
- handler.failed(ex);
+ try {
+ handler.failed(ex);
+ } catch (Throwable t) {
+ // The future has to complete even if the handler fails, otherwise waiting threads hang forever
+ if (t != ex) {
+ ex.addSuppressed(t);
+ }
+ }
}
delegate.completeExceptionally(ex);
@@ -131,7 +142,13 @@ public class JaxrsClientCallback<T> extends ClientCallback {
return getObject(callback.get()[0]);
} catch (InterruptedException ex) {
if (callback.handler != null) {
- callback.handler.failed(ex);
+ try {
+ callback.handler.failed(ex);
+ } catch (Throwable t) {
+ if (t != ex) {
+ ex.addSuppressed(t);
+ }
+ }
}
throw ex;
}
@@ -142,7 +159,13 @@ public class JaxrsClientCallback<T> extends ClientCallback {
return getObject(callback.get(timeout, unit)[0]);
} catch (InterruptedException ex) {
if (callback.handler != null) {
- callback.handler.failed(ex);
+ try {
+ callback.handler.failed(ex);
+ } catch (Throwable t) {
+ if (t != ex) {
+ ex.addSuppressed(t);
+ }
+ }
}
throw ex;
}
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
index 74f79e11681..ef57df668a5 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
@@ -1033,12 +1033,21 @@ public class WebClient extends AbstractClient {
}
}
if (cb.getResponseClass() == null || Response.class.equals(cb.getResponseClass())) {
- cb.handleResponse(message, new Object[] {r});
+ try {
+ cb.handleResponse(message, new Object[] {r});
+ } catch (Throwable t) {
+ cb.handleException(message, t);
+ }
} else if (r.getStatus() >= 300) {
cb.handleException(message, convertToWebApplicationException(r));
} else {
- cb.handleResponse(message, new Object[] {r.getEntity()});
- closeAsyncResponseIfPossible(r, message, cb);
+ try {
+ cb.handleResponse(message, new Object[] {r.getEntity()});
+ } catch (Throwable t) {
+ cb.handleException(message, t);
+ } finally {
+ closeAsyncResponseIfPossible(r, message, cb);
+ }
}
}
}
diff --git a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/JaxrsClientCallbackTest.java b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/JaxrsClientCallbackTest.java
index 4653414c22f..94cfe6094d6 100644
--- a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/JaxrsClientCallbackTest.java
+++ b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/JaxrsClientCallbackTest.java
@@ -41,6 +41,7 @@ import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertThrows;
@@ -182,6 +183,74 @@ public class JaxrsClientCallbackTest {
future.get(10, TimeUnit.MILLISECONDS);
}
+ @Test
+ public void testHandleResponseCallbackThrows() throws Exception {
+ final RuntimeException handlerException = new RuntimeException("completed failed");
+ useThrowingHandler(handlerException);
+
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+ Object[] result = new String[] {"results"};
+ // Callers invoke handleException() if handleResponse() throws
+ schedule(barrier, () -> {
+ try {
+ callback.handleResponse(ctx, result);
+ } catch (Throwable t) {
+ callback.handleException(ctx, t);
+ }
+ });
+ barrier.await(5, TimeUnit.SECONDS);
+
+ ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get(5, TimeUnit.SECONDS));
+ assertThat(ex.getCause(), sameInstance(handlerException));
+ assertThat(handlerException.getSuppressed().length, equalTo(0));
+ assertThrows(ExecutionException.class, () -> future.get());
+ assertThat(future.isCancelled(), equalTo(false));
+ assertThat(future.isDone(), equalTo(true));
+ }
+
+ @Test
+ public void testHandleExceptionCallbackThrows() throws Exception {
+ final RuntimeException handlerException = new RuntimeException("failed failed");
+ useThrowingHandler(handlerException);
+
+ final RuntimeException cause = new RuntimeException("invocation failed");
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+ schedule(barrier, () -> callback.handleException(ctx, cause));
+ barrier.await(5, TimeUnit.SECONDS);
+
+ ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get(5, TimeUnit.SECONDS));
+ assertThat(ex.getCause(), sameInstance(cause));
+ assertThat(cause.getSuppressed(), equalTo(new Throwable[] {handlerException}));
+ assertThat(future.isCancelled(), equalTo(false));
+ assertThat(future.isDone(), equalTo(true));
+ }
+
+ @Test
+ public void testHandleCancellationCallbackThrows() throws Exception {
+ useThrowingHandler(new RuntimeException("failed failed"));
+
+ assertThat(future.cancel(true), equalTo(true));
+ assertThrows(InterruptedException.class, () -> future.get(10, TimeUnit.MILLISECONDS));
+ assertThat(future.isCancelled(), equalTo(true));
+ assertThat(future.isDone(), equalTo(true));
+ }
+
+ private void useThrowingHandler(final RuntimeException handlerException) {
+ handler = new InvocationCallback<String>() {
+ @Override
+ public void failed(Throwable throwable) {
+ throw handlerException;
+ }
+
+ @Override
+ public void completed(String response) {
+ throw handlerException;
+ }
+ };
+ callback = new JaxrsClientCallback<String>(handler, String.class, null);
+ future = (JaxrsResponseFuture<String>)callback.createFuture();
+ }
+
private void schedule(CyclicBarrier barrier, Runnable runnable) {
executor.schedule(() -> {
barrier.await(5, TimeUnit.SECONDS);
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
index f56a9ee2b3c..c45661e0c56 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
@@ -410,6 +410,28 @@ public class JAXRSAsyncClientTest extends AbstractBusClientServerTestBase {
wc.close();
}
+ @Test
+ public void testGetBookAsyncCallbackThrows() throws Exception {
+ String address = "http://localhost:" + PORT + "/bookstore/books/123";
+ WebClient wc = createWebClient(address);
+ final RuntimeException handlerException = new RuntimeException("completed failed");
+ InvocationCallback<Book> callback = new InvocationCallback<Book>() {
+ public void completed(Book response) {
+ throw handlerException;
+ }
+
+ public void failed(Throwable error) {
+ }
+ };
+ try {
+ wc.async().get(callback).get(10, TimeUnit.SECONDS);
+ fail("Exception expected");
+ } catch (ExecutionException ex) {
+ assertTrue(ex.getCause() == handlerException);
+ }
+ wc.close();
+ }
+
@Test
public void testClientResponseFilter() throws Exception {
final String address = "http://localhost:" + PORT + "/bookstore/books/wildcard";