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 0764caccd21 Fix code scanning low warning: Exceptions should not be thrown from servlet methods 0764caccd21 is described below commit 0764caccd21b3a57cf90121d82c67eb9c71dc80d Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Dec 27 14:50:51 2022 +0100 Fix code scanning low warning: Exceptions should not be thrown from servlet methods --- .../component/jetty/CamelContinuationServlet.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java index 3a542729d73..0f3d51ea68e 100644 --- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java @@ -59,9 +59,25 @@ public class CamelContinuationServlet extends CamelServlet { private final Map<String, String> expiredExchanges = new ConcurrentHashMap<>(); @Override - protected void doService(final HttpServletRequest request, final HttpServletResponse response) - throws ServletException, IOException { + protected void doService(HttpServletRequest request, HttpServletResponse response) { log.trace("Service: {}", request); + try { + handleDoService(request, response); + } catch (Exception e) { + // do not leak exception back to caller + log.warn("Error handling request due to: " + e.getMessage(), e); + try { + if (!response.isCommitted()) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } catch (Exception e1) { + // ignore + } + } + } + + protected void handleDoService(final HttpServletRequest request, final HttpServletResponse response) + throws ServletException, IOException { // is there a consumer registered for the request. HttpConsumer consumer = getServletResolveConsumerStrategy().resolve(request, getConsumers());