Repository: asterixdb Updated Branches: refs/heads/master 759b6987e -> 2cef3fd17
[ASTERIXDB-2030][FAIL] Do not reformat error messages - user model changes: no - storage format changes: no - interface changes: no Details: - if the error message is already formatted, just reuse it - Add test case Change-Id: Idd922bca36c7b40903c8b7abbe3386fbedd9c77b Reviewed-on: https://asterix-gerrit.ics.uci.edu/1932 Sonar-Qube: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Contrib: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Yingyi Bu <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/2cef3fd1 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/2cef3fd1 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/2cef3fd1 Branch: refs/heads/master Commit: 2cef3fd17377fdd92f1897428b7bbf5bc073ef62 Parents: 759b698 Author: Murtadha Hubail <[email protected]> Authored: Thu Aug 10 15:56:09 2017 +0300 Committer: Murtadha Hubail <[email protected]> Committed: Thu Aug 10 12:38:11 2017 -0700 ---------------------------------------------------------------------- .../hyracks/api/util/ErrorMessageUtil.java | 4 ++ .../api/test/HyracksDataExceptionTest.java | 43 ++++++++++++++++++++ 2 files changed, 47 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2cef3fd1/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ErrorMessageUtil.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ErrorMessageUtil.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ErrorMessageUtil.java index 467d148..285e932 100644 --- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ErrorMessageUtil.java +++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ErrorMessageUtil.java @@ -91,6 +91,10 @@ public class ErrorMessageUtil { if (!NONE.equals(component)) { fmt.format("%1$s%2$04d: ", component, errorCode); } + // if the message is already formatted, just return it + if (!fmt.toString().isEmpty() && message.startsWith(fmt.toString())) { + return message; + } fmt.format(message == null ? "null" : message, (Object[]) params); return fmt.out().toString(); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2cef3fd1/hyracks-fullstack/hyracks/hyracks-api/src/test/java/org/apache/hyracks/api/test/HyracksDataExceptionTest.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/test/java/org/apache/hyracks/api/test/HyracksDataExceptionTest.java b/hyracks-fullstack/hyracks/hyracks-api/src/test/java/org/apache/hyracks/api/test/HyracksDataExceptionTest.java new file mode 100644 index 0000000..23a1caa --- /dev/null +++ b/hyracks-fullstack/hyracks/hyracks-api/src/test/java/org/apache/hyracks/api/test/HyracksDataExceptionTest.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.hyracks.api.test; + +import org.apache.hyracks.api.exceptions.ErrorCode; +import org.apache.hyracks.api.exceptions.HyracksDataException; +import org.apache.hyracks.api.util.ErrorMessageUtil; +import org.junit.Assert; +import org.junit.Test; + +public class HyracksDataExceptionTest { + + @Test + public void returnedMessageWithComponentTest() { + HyracksDataException cause = HyracksDataException.create(ErrorCode.ERROR_PROCESSING_TUPLE, 3); + HyracksDataException causeWithNodeId = HyracksDataException.create(cause, "nc1"); + Assert.assertEquals(cause.getMessage(), causeWithNodeId.getMessage()); + } + + @Test + public void returnedMessageWithNoComponentTest() { + HyracksDataException cause = new HyracksDataException(ErrorMessageUtil.NONE, ErrorCode.ERROR_PROCESSING_TUPLE, + ErrorCode.getErrorMessage(ErrorCode.ERROR_PROCESSING_TUPLE), null, null, 2); + HyracksDataException causeWithNodeId = HyracksDataException.create(cause, "nc1"); + Assert.assertEquals(cause.getMessage(), causeWithNodeId.getMessage()); + } +} \ No newline at end of file
