summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-07-05 12:27:17 -0400
committerJames Moger <james.moger@gitblit.com>2014-07-05 12:27:17 -0400
commit498cdca0cc3a7545311877a0fb43586ef113a801 (patch)
tree47539856156581f79464d0972a7a65a9d2478ac3
parent9b575e8fac8d5e17e77cc284092abd856ddec8ac (diff)
downloadgitblit-498cdca0cc3a7545311877a0fb43586ef113a801.tar.gz
gitblit-498cdca0cc3a7545311877a0fb43586ef113a801.zip
Fix possible NPE in RawServlet
-rw-r--r--src/main/java/com/gitblit/servlet/RawServlet.java9
1 files changed, 9 insertions, 0 deletions
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);