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) {