From notifications-return-116052-archive-asf-public=cust-asf.ponee.io@asterixdb.apache.org Thu Aug 9 22:01:06 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 51D8B18065B for ; Thu, 9 Aug 2018 22:01:05 +0200 (CEST) Received: (qmail 23523 invoked by uid 500); 9 Aug 2018 20:01:04 -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 23514 invoked by uid 99); 9 Aug 2018 20:01:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2018 20:01:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 141FFCFF20 for ; Thu, 9 Aug 2018 20:01:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.072 X-Spam-Level: **** X-Spam-Status: No, score=4.072 tagged_above=-999 required=6.31 tests=[MISSING_HEADERS=1.207, RCVD_IN_DNSWL_NONE=-0.0001, REPLYTO_WITHOUT_TO_CC=1.946, SPF_FAIL=0.919] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id wP12gXu8WwLH for ; Thu, 9 Aug 2018 20:01:03 +0000 (UTC) Received: from vitalstatistix.ics.uci.edu (vitalstatistix.ics.uci.edu [128.195.52.38]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 173025F20B for ; Thu, 9 Aug 2018 20:01:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vitalstatistix.ics.uci.edu (Postfix) with ESMTP id 9C7DA10042F; Thu, 9 Aug 2018 13:01:02 -0700 (PDT) Date: Thu, 9 Aug 2018 13:01:02 -0700 From: "Murtadha Hubail (Code Review)" Message-ID: Reply-To: mhubail@apache.org X-Gerrit-MessageType: newchange Subject: Change in asterixdb[master]: [NO ISSUE][FAIL] Use Formatted Exception For No Statement Pr... X-Gerrit-Change-Id: Ibe86b4e6703a3e0e228d96d37e371cc2295ccc12 X-Gerrit-ChangeURL: X-Gerrit-Commit: 61b83a9626a85ba0fa1cecd48baa1b02f893db95 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.12.7 Murtadha Hubail has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/2869 Change subject: [NO ISSUE][FAIL] Use Formatted Exception For No Statement Provided ...................................................................... [NO ISSUE][FAIL] Use Formatted Exception For No Statement Provided - user model changes: no - storage format changes: no - interface changes: no Change-Id: Ibe86b4e6703a3e0e228d96d37e371cc2295ccc12 --- M asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceRequestParameters.java M asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java M asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties 4 files changed, 10 insertions(+), 4 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/69/2869/1 diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceRequestParameters.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceRequestParameters.java index d0c59b5..16a2105 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceRequestParameters.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceRequestParameters.java @@ -201,7 +201,7 @@ ObjectNode on = OBJECT_MAPPER.createObjectNode(); on.put("host", host); on.put("path", path); - on.put("statement", JSONUtil.escape(new StringBuilder(), statement).toString()); + on.put("statement", statement != null ? JSONUtil.escape(new StringBuilder(), statement).toString() : null); on.put("pretty", pretty); on.put("mode", mode); on.put("clientContextID", clientContextID); diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java index 54b5baa..c05ce6f 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java @@ -43,7 +43,8 @@ import org.apache.asterix.common.config.GlobalConfig; import org.apache.asterix.common.context.IStorageComponentProvider; import org.apache.asterix.common.dataflow.ICcApplicationContext; -import org.apache.asterix.common.exceptions.AsterixException; +import org.apache.asterix.common.exceptions.ErrorCode; +import org.apache.asterix.common.exceptions.RuntimeDataException; import org.apache.asterix.compiler.provider.ILangCompilationProvider; import org.apache.asterix.lang.aql.parser.TokenMgrError; import org.apache.asterix.lang.common.base.IParser; @@ -416,7 +417,10 @@ if (HttpUtil.ContentType.APPLICATION_JSON.equals(contentType)) { try { JsonNode jsonRequest = OBJECT_MAPPER.readTree(HttpUtil.getRequestBody(request)); - param.setStatement(jsonRequest.get(Parameter.STATEMENT.str()).asText()); + final String statementParam = Parameter.STATEMENT.str(); + if (jsonRequest.has(statementParam)) { + param.setStatement(jsonRequest.get(statementParam).asText()); + } param.setFormat(toLower(getOptText(jsonRequest, Parameter.FORMAT.str()))); param.setPretty(getOptBoolean(jsonRequest, Parameter.PRETTY.str(), false)); param.setMode(toLower(getOptText(jsonRequest, Parameter.MODE.str()))); @@ -532,7 +536,7 @@ List warnings = Collections.emptyList(); // we don't have any warnings yet try { if (param.getStatement() == null || param.getStatement().isEmpty()) { - throw new AsterixException("Empty request, no statement provided"); + throw new RuntimeDataException(ErrorCode.NO_STATEMENT_PROVIDED); } String statementsText = param.getStatement() + ";"; Map optionalParams = null; diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java index 8af1ec7..3fbce28 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java @@ -79,6 +79,7 @@ public static final int TYPE_MISMATCH_GENERIC = 37; public static final int DIFFERENT_LIST_TYPE_ARGS = 38; public static final int INTEGER_VALUE_EXPECTED = 39; + public static final int NO_STATEMENT_PROVIDED = 40; public static final int UNSUPPORTED_JRE = 100; diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties index 63e0cda..f0dfd1a 100644 --- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties +++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties @@ -73,6 +73,7 @@ 36 = Cannot compare non-primitive values 38 = Input contains different list types 39 = Expected integer value, got %1$s +40 = No statement provided 100 = Unsupported JRE: %1$s -- To view, visit https://asterix-gerrit.ics.uci.edu/2869 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibe86b4e6703a3e0e228d96d37e371cc2295ccc12 Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Murtadha Hubail