From 05d9c4cf29447b72a122f43770e830d6a07a9c99 Mon Sep 17 00:00:00 2001 From: Tigran Mkrtchyan Date: Tue, 21 Nov 2023 13:22:00 +0100 Subject: [PATCH] webdav: do not log stacktrace if non-existing `well-known` is requested No reaouns to log a stacktrace Fixes: #7434 Acked-by: Lea Morschel Acked-by: Albert Rossi Target: master, 9.2 Require-book: no Require-notes: yes --- .../dcache/services/httpd/handlers/WellKnownHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/dcache/src/main/java/org/dcache/services/httpd/handlers/WellKnownHandler.java b/modules/dcache/src/main/java/org/dcache/services/httpd/handlers/WellKnownHandler.java index 42c7a667814..a3eb0fb5639 100644 --- a/modules/dcache/src/main/java/org/dcache/services/httpd/handlers/WellKnownHandler.java +++ b/modules/dcache/src/main/java/org/dcache/services/httpd/handlers/WellKnownHandler.java @@ -59,8 +59,10 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ package org.dcache.services.httpd.handlers; +import diskCacheV111.util.CacheException; import dmg.util.HttpRequest; import java.io.IOException; +import java.net.URISyntaxException; import java.util.Optional; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -91,7 +93,8 @@ public void handle(String target, Request baseRequest, String[] tokens = proxy.getRequestTokens(); Optional factory = factoryProvider.getFactory(tokens[1]); if (factory.isEmpty()) { - throw new OnErrorException("No such endpoint"); + response.sendError(HttpServletResponse.SC_NOT_FOUND, "No such endpoint"); + return; } WellKnownProducer producer = factory.get().createProducer(); @@ -108,8 +111,8 @@ public void handle(String target, Request baseRequest, baseRequest.setHandled(true); } - } catch (Exception t) { - throw new ServletException("WellKnownHandler", t); + } catch (CacheException | URISyntaxException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } }