Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4CFE6200C8F for ; Fri, 9 Jun 2017 20:24:28 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4BB34160BCA; Fri, 9 Jun 2017 18:24:28 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6B5AB160BB6 for ; Fri, 9 Jun 2017 20:24:27 +0200 (CEST) Received: (qmail 10691 invoked by uid 500); 9 Jun 2017 18:24:26 -0000 Mailing-List: contact notifications-help@asterixdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.apache.org Delivered-To: mailing list notifications@asterixdb.apache.org Received: (qmail 10682 invoked by uid 99); 9 Jun 2017 18:24:26 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Jun 2017 18:24:26 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 33F8C1A049E for ; Fri, 9 Jun 2017 18:24:26 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.919 X-Spam-Level: X-Spam-Status: No, score=0.919 tagged_above=-999 required=6.31 tests=[SPF_FAIL=0.919] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id EqzD2Rc0Helr for ; Fri, 9 Jun 2017 18:24:24 +0000 (UTC) Received: from unhygienix.ics.uci.edu (unhygienix.ics.uci.edu [128.195.14.130]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 166645F569 for ; Fri, 9 Jun 2017 18:24:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by unhygienix.ics.uci.edu (Postfix) with ESMTP id 7DF10242098; Fri, 9 Jun 2017 11:24:23 -0700 (PDT) Date: Fri, 9 Jun 2017 11:24:23 -0700 From: "Michael Blow (Code Review)" Message-ID: Reply-To: mblow@apache.org X-Gerrit-MessageType: newchange Subject: Change in asterixdb[master]: Suppress stacktraces on expected exceptions X-Gerrit-Change-Id: Ifce33d34d7ef3551613a67fdbfe45b143c46be86 X-Gerrit-ChangeURL: X-Gerrit-Commit: de6a64236e2004710fc8a440598abf4492ff5452 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.12.7 To: undisclosed-recipients:; archived-at: Fri, 09 Jun 2017 18:24:28 -0000 Michael Blow has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/1823 Change subject: Suppress stacktraces on expected exceptions ...................................................................... Suppress stacktraces on expected exceptions Change-Id: Ifce33d34d7ef3551613a67fdbfe45b143c46be86 --- M asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java 1 file changed, 37 insertions(+), 11 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/23/1823/1 diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java index 55c98d1..7570672 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java @@ -27,6 +27,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; @@ -91,8 +92,8 @@ public class TestExecutor { /* - * Static variables - */ + * Static variables + */ protected static final Logger LOGGER = Logger.getLogger(TestExecutor.class.getName()); // see // https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers/417184 @@ -453,25 +454,50 @@ throws Exception { if (!responseCodeValidator.test(httpResponse.getStatusLine().getStatusCode())) { String errorBody = EntityUtils.toString(httpResponse.getEntity()); - String exceptionMsg; + String[] errors; try { // First try to parse the response for a JSON error response. ObjectMapper om = new ObjectMapper(); JsonNode result = om.readTree(errorBody); - String[] errors = { result.get("error-code").asText(), result.get("summary").asText(), + errors = new String[] { result.get("error-code").get(1).asText(), result.get("summary").asText(), result.get("stacktrace").asText() }; - GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, errors[2]); - exceptionMsg = "HTTP operation failed: " + errors[0] + "\nSTATUS LINE: " + httpResponse.getStatusLine() - + "\nSUMMARY: " + errors[1] + "\nSTACKTRACE: " + errors[2]; } catch (Exception e) { // whoops, not JSON (e.g. 404) - just include the body GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, errorBody); - exceptionMsg = "HTTP operation failed:" + "\nSTATUS LINE: " + httpResponse.getStatusLine() - + "\nERROR_BODY: " + errorBody; + throw new Exception("HTTP operation failed:" + "\nSTATUS LINE: " + httpResponse.getStatusLine() + + "\nERROR_BODY: " + errorBody, e); } - throw new Exception(exceptionMsg); + throw new ParsedException("HTTP operation failed: " + errors[0] + "\nSTATUS LINE: " + + httpResponse.getStatusLine() + "\nSUMMARY: " + errors[2].split("\n")[0], errors[2]); } return httpResponse; + } + + static class ParsedException extends Exception { + + private final String savedStack; + + ParsedException(String message, String stackTrace) { + super(message); + savedStack = stackTrace; + } + + @Override + public String toString() { + return getMessage(); + } + + @Override + public void printStackTrace(PrintStream s) { + super.printStackTrace(s); + s.println("Caused by: " + savedStack); + } + + @Override + public void printStackTrace(PrintWriter s) { + super.printStackTrace(s); + s.println("Caused by: " + savedStack); + } } public InputStream executeQuery(String str, OutputFormat fmt, URI uri, List params) @@ -1260,7 +1286,7 @@ if (failedGroup != null) { failedGroup.getTestCase().add(testCaseCtx.getTestCase()); } - throw new Exception("Test \"" + testFile + "\" FAILED!", e); + throw new Exception("Test \"" + testFile + "\" FAILED!"); } } finally { if (numOfFiles == testFileCtxs.size()) { -- To view, visit https://asterix-gerrit.ics.uci.edu/1823 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifce33d34d7ef3551613a67fdbfe45b143c46be86 Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow