From: James Moger Date: Sat, 5 Jul 2014 16:27:17 +0000 (-0400) Subject: Fix possible NPE in RawServlet X-Git-Tag: v1.6.1~68^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Ftickets%2F37%2F137%2F1;p=gitblit.git Fix possible NPE in RawServlet --- diff --git a/src/main/java/com/gitblit/servlet/RawServlet.java b/src/main/java/com/gitblit/servlet/RawServlet.java index 15e036ea..e0f064c3 100644 --- a/src/main/java/com/gitblit/servlet/RawServlet.java +++ b/src/main/java/com/gitblit/servlet/RawServlet.java @@ -254,6 +254,15 @@ public class RawServlet extends DaggerServlet { // load, interpret, and serve text content as UTF-8 String [] encodings = runtimeManager.getSettings().getStrings(Keys.web.blobEncodings).toArray(new String[0]); String content = JGitUtils.getStringContent(r, commit.getTree(), requestedPath, encodings); + if (content == null) { + logger.error("RawServlet Failed to load {} {} {}", repository, commit.getName(), path); + String str = MessageFormat.format( + "# Error\nSorry, the requested resource **{0}** was not found.", + requestedPath); + response.setStatus(HttpServletResponse.SC_NOT_FOUND); + error(response, str); + return; + } byte [] bytes = content.getBytes(Constants.ENCODING); response.setContentLength(bytes.length);