Skip to content

Commit 68cb9e8

Browse files
committed
add null check for missing file
1 parent ffe46f2 commit 68cb9e8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: tds/src/main/java/thredds/servlet/ServletUtil.java

+6
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ public static void writeMFileToResponse(HttpServletRequest request, HttpServletR
282282
final String ncmlLocation = TdsRequestedDataset.getLocationFromNcml(requestPath);
283283
final String location =
284284
ncmlLocation != null ? ncmlLocation : TdsRequestedDataset.getLocationFromRequestPath(requestPath);
285+
286+
if (location == null) {
287+
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Could not find file with URL path: " + requestPath);
288+
return;
289+
}
290+
285291
final MFile file = MFiles.create(location);
286292

287293
if (file == null) {

0 commit comments

Comments
 (0)