From 68cb9e871ab77319ed651d769d33acde12a6fbcf Mon Sep 17 00:00:00 2001 From: Megan Lerman Date: Wed, 20 Dec 2023 16:10:59 -0800 Subject: [PATCH] add null check for missing file --- tds/src/main/java/thredds/servlet/ServletUtil.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tds/src/main/java/thredds/servlet/ServletUtil.java b/tds/src/main/java/thredds/servlet/ServletUtil.java index e18a347817..5bb60aa68e 100644 --- a/tds/src/main/java/thredds/servlet/ServletUtil.java +++ b/tds/src/main/java/thredds/servlet/ServletUtil.java @@ -282,6 +282,12 @@ public static void writeMFileToResponse(HttpServletRequest request, HttpServletR final String ncmlLocation = TdsRequestedDataset.getLocationFromNcml(requestPath); final String location = ncmlLocation != null ? ncmlLocation : TdsRequestedDataset.getLocationFromRequestPath(requestPath); + + if (location == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND, "Could not find file with URL path: " + requestPath); + return; + } + final MFile file = MFiles.create(location); if (file == null) {