incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r921422 - in /sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl: SlingPostServlet.java helper/MediaRangeList.java
Date Wed, 10 Mar 2010 16:14:24 GMT
Author: bdelacretaz
Date: Wed Mar 10 16:14:23 2010
New Revision: 921422

URL: http://svn.apache.org/viewvc?rev=921422&view=rev
Log:
SLING-1336 - avoid NPE if no Accept header

Modified:
    sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
    sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/MediaRangeList.java

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java?rev=921422&r1=921421&r2=921422&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
(original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
Wed Mar 10 16:14:23 2010
@@ -215,7 +215,7 @@ public class SlingPostServlet extends Sl
      HtmlResponse createHtmlResponse(SlingHttpServletRequest req) {
         @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
         MediaRangeList mediaRangeList = new MediaRangeList(req);
-        if (mediaRangeList.prefer("text/html", JSONResponse.RESPONSE_CONTENT_TYPE).equals(JSONResponse.RESPONSE_CONTENT_TYPE))
{
+        if (JSONResponse.RESPONSE_CONTENT_TYPE.equals(mediaRangeList.prefer("text/html",
JSONResponse.RESPONSE_CONTENT_TYPE))) {
             return new JSONResponse();
         } else {
             return new HtmlResponse();

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/MediaRangeList.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/MediaRangeList.java?rev=921422&r1=921421&r2=921422&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/MediaRangeList.java
(original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/MediaRangeList.java
Wed Mar 10 16:14:23 2010
@@ -145,7 +145,8 @@ public class MediaRangeList extends Tree
         for (String mediaRange : mediaRanges) {
             ranges.add(new MediaRange(mediaRange));
         }
-        return prefer(ranges).toString();
+        final MediaRange preferred = prefer(ranges);
+        return(preferred == null ? null : preferred.toString());
     }
 
     /**



Mime
View raw message