marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wik...@apache.org
Subject [4/4] git commit: MARMOTTA-562: fixed potential npe rendering exceptions
Date Wed, 05 Nov 2014 14:31:04 GMT
MARMOTTA-562: fixed potential npe rendering exceptions


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/0965f73f
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/0965f73f
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/0965f73f

Branch: refs/heads/develop
Commit: 0965f73f27e49efc67fde688f81895cc14cadf04
Parents: 9dfc605
Author: Sergio Fernández <wikier@apache.org>
Authored: Wed Nov 5 11:47:35 2014 +0100
Committer: Sergio Fernández <wikier@apache.org>
Committed: Wed Nov 5 15:30:50 2014 +0100

----------------------------------------------------------------------
 .../exceptionmappers/HttpErrorExceptionMapper.java | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/0965f73f/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jaxrs/exceptionmappers/HttpErrorExceptionMapper.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jaxrs/exceptionmappers/HttpErrorExceptionMapper.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jaxrs/exceptionmappers/HttpErrorExceptionMapper.java
index 99adeba..69aabfe 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jaxrs/exceptionmappers/HttpErrorExceptionMapper.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jaxrs/exceptionmappers/HttpErrorExceptionMapper.java
@@ -17,6 +17,7 @@
 package org.apache.marmotta.platform.core.jaxrs.exceptionmappers;
 
 import freemarker.template.TemplateException;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
 import org.apache.marmotta.platform.core.api.templating.TemplatingService;
 import org.apache.marmotta.platform.core.exception.HttpErrorException;
@@ -66,12 +67,18 @@ public class HttpErrorExceptionMapper implements CDIExceptionMapper<HttpErrorExc
         Map<String, Object> data = new HashMap<String, Object>();
         data.put("status", exception.getStatus());
         data.put("reason", exception.getReason());
-        data.put("uri", exception.getUri());
+
         data.put("message", exception.getMessage());
-        try {
-            data.put("encoded_uri", URLEncoder.encode(exception.getUri(), "UTF-8"));
-        } catch (UnsupportedEncodingException uee) {
-            data.put("encoded_uri", exception.getUri());
+        if (StringUtils.isNotBlank(exception.getUri())) {
+            data.put("uri", exception.getUri());
+            try {
+                data.put("encoded_uri", URLEncoder.encode(exception.getUri(), "UTF-8"));
+            } catch (UnsupportedEncodingException uee) {
+                data.put("encoded_uri", exception.getUri());
+            }
+        } else {
+            data.put("uri", "");
+            data.put("encoded_uri", "");
         }
 
         Response.ResponseBuilder responseBuilder;


Mime
View raw message