asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject asterixdb git commit: Improved Error Reporting When Repsonse Is Non-JSON
Date Mon, 22 Aug 2016 03:50:30 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 80fbd9983 -> 6cc59cacb


Improved Error Reporting When Repsonse Is Non-JSON

Change-Id: I2d27945a1d39bdc3304abcb8fd75c5173aee74c4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1099
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/6cc59cac
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/6cc59cac
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/6cc59cac

Branch: refs/heads/master
Commit: 6cc59cacbcde96e1b143c2c54326459cddfee2f2
Parents: 80fbd998
Author: Michael Blow <mblow@apache.org>
Authored: Sun Aug 21 22:09:35 2016 -0400
Committer: Till Westmann <tillw@apache.org>
Committed: Sun Aug 21 20:50:08 2016 -0700

----------------------------------------------------------------------
 .../apache/asterix/test/aql/TestExecutor.java   | 25 +++++++++++++-------
 1 file changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6cc59cac/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/aql/TestExecutor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/aql/TestExecutor.java
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/aql/TestExecutor.java
index 3321065..47290e7 100644
--- a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/aql/TestExecutor.java
+++ b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/aql/TestExecutor.java
@@ -58,6 +58,7 @@ import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.client.StandardHttpRequestRetryHandler;
 import org.apache.http.util.EntityUtils;
+import org.json.JSONException;
 import org.json.JSONObject;
 
 public class TestExecutor {
@@ -267,14 +268,22 @@ public class TestExecutor {
             // In future this may be changed depending on the requested
             // output format sent to the servlet.
             String errorBody = EntityUtils.toString(httpResponse.getEntity());
-            JSONObject result = new JSONObject(errorBody);
-            String[] errors = { result.getJSONArray("error-code").getString(0), result.getString("summary"),
-                    result.getString("stacktrace") };
-            GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, errors[2]);
-            String exceptionMsg = "HTTP operation failed: " + errors[0]
-                    + "\nSTATUS LINE: " + httpResponse.getStatusLine()
-                    + "\nSUMMARY: " + errors[1] + "\nSTACKTRACE: " + errors[2];
-            throw new Exception(exceptionMsg);
+            try {
+                JSONObject result = new JSONObject(errorBody);
+                String[] errors = {result.getJSONArray("error-code").getString(0), result.getString("summary"),
+                        result.getString("stacktrace")};
+                GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, errors[2]);
+                String exceptionMsg = "HTTP operation failed: " + errors[0]
+                        + "\nSTATUS LINE: " + httpResponse.getStatusLine()
+                        + "\nSUMMARY: " + errors[1] + "\nSTACKTRACE: " + errors[2];
+                throw new Exception(exceptionMsg);
+            } catch (JSONException e) {
+                GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, errorBody);
+                String exceptionMsg = "HTTP operation failed: response is not valid-JSON
(see nested exception)"
+                        + "\nSTATUS LINE: " + httpResponse.getStatusLine()
+                        + "\nERROR_BODY: " + errorBody;
+                throw new Exception(exceptionMsg, e);
+            }
         }
         return httpResponse;
     }


Mime
View raw message