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 eadb8db368a Fix code scanning low warning: Exceptions should not be thrown from servlet methods eadb8db368a is described below commit eadb8db368ad862de14e7794eca84002b1ddc098 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Dec 26 16:22:15 2022 +0100 Fix code scanning low warning: Exceptions should not be thrown from servlet methods --- .../atmosphere/websocket/CamelWebSocketServlet.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java index 030fffe0811..1a583e5c5bb 100644 --- a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java +++ b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java @@ -48,9 +48,25 @@ public class CamelWebSocketServlet extends CamelHttpTransportServlet { } @Override - protected void doService(HttpServletRequest request, 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(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { // Is there a consumer registered for the request. HttpConsumer consumer = getServletResolveConsumerStrategy().resolve(request, getConsumers()); if (consumer == null) {