This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
The following commit(s) were added to refs/heads/master by this push: new aec7856 knative(http): fix request handler exception handling aec7856 is described below commit aec785608d6a0a436a6dad9301b0e5b281ffbbbc Author: Luca Burgazzoli <lburgazz...@gmail.com> AuthorDate: Thu Oct 1 13:06:52 2020 +0200 knative(http): fix request handler exception handling --- .../camel/component/knative/http/KnativeHttpConsumer.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpConsumer.java b/components/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpConsumer.java index bb1b932..13c5c42 100644 --- a/components/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpConsumer.java +++ b/components/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpConsumer.java @@ -188,6 +188,8 @@ public class KnativeHttpConsumer extends DefaultConsumer { false, result -> { try { + Throwable failure = null; + if (result.succeeded()) { try { HttpServerResponse response = toHttpResponse(request, exchange.getMessage()); @@ -196,10 +198,8 @@ public class KnativeHttpConsumer extends DefaultConsumer { if (request.response().getStatusCode() != 204 && configuration.isReply()) { body = computeResponseBody(exchange.getMessage()); - // set the content type in the response. String contentType = MessageHelper.getContentType(exchange.getMessage()); if (contentType != null) { - // set content-type response.putHeader(Exchange.CONTENT_TYPE, contentType); } } @@ -211,12 +211,15 @@ public class KnativeHttpConsumer extends DefaultConsumer { request.response().end(); } } catch (Exception e) { - getExceptionHandler().handleException(e); + failure = e; } } else if (result.failed()) { - getExceptionHandler().handleException(result.cause()); + failure = result.cause(); + } - routingContext.fail(result.cause()); + if (failure != null) { + getExceptionHandler().handleException(failure); + routingContext.fail(failure); } } finally { doneUoW(exchange);