handle missing format parameter

Change-Id: I90b6da30e2e3a52d68cdf29b0026125dca4da3e4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1046
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
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;
@@ -229,6 +232,10 @@
         return null;
     }
 
+    private static String toLower(String s) {
+        return s != null ? s.toLowerCase() : s;
+    }
+
     private static SessionConfig.OutputFormat getFormat(String format) {
         if (format != null) {
             if (format.startsWith(MediaType.CSV.str())) {
@@ -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);