Till Westmann has submitted this change and it was merged.

Change subject: handle missing format parameter
......................................................................


handle missing format parameter

Change-Id: I90b6da30e2e3a52d68cdf29b0026125dca4da3e4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1046
Sonar-Qube: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
Integration-Tests: Jenkins <[email protected]>
Reviewed-by: Yingyi Bu <[email protected]>
---
M 
asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
1 file changed, 8 insertions(+), 1 deletion(-)

Approvals:
  Yingyi Bu: Looks good to me, approved
  Jenkins: Verified; No violations found; Verified



diff --git 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
index f208694..d3507d8 100644
--- 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
+++ 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
@@ -215,6 +215,9 @@
     }
 
     private static String getParameterValue(String content, String attribute) {
+        if (content == null || attribute == null) {
+            return null;
+        }
         int sc = content.indexOf(';');
         if (sc < 0) {
             return null;
@@ -227,6 +230,10 @@
             return content.substring(eq + 1).trim().toLowerCase();
         }
         return null;
+    }
+
+    private static String toLower(String s) {
+        return s != null ? s.toLowerCase() : s;
     }
 
     private static SessionConfig.OutputFormat getFormat(String format) {
@@ -262,7 +269,7 @@
             return app;
         };
 
-        String formatstr = 
request.getParameter(Parameter.FORMAT.str()).toLowerCase();
+        final String formatstr = 
toLower(request.getParameter(Parameter.FORMAT.str()));
         SessionConfig.OutputFormat format = getFormat(formatstr);
         SessionConfig sessionConfig = new SessionConfig(resultWriter, format, 
resultPrefix, resultPostfix);
         sessionConfig.set(SessionConfig.FORMAT_WRAPPER_ARRAY, true);

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1046
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I90b6da30e2e3a52d68cdf29b0026125dca4da3e4
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Till Westmann <[email protected]>
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Till Westmann <[email protected]>
Gerrit-Reviewer: Yingyi Bu <[email protected]>

Reply via email to