Murtadha Hubail has submitted this change and it was merged. Change subject: [ASTERIXDB-2030][FAIL] Do not reformat error messages ......................................................................
[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]> --- M hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ErrorMessageUtil.java A hyracks-fullstack/hyracks/hyracks-api/src/test/java/org/apache/hyracks/api/test/HyracksDataExceptionTest.java 2 files changed, 47 insertions(+), 0 deletions(-) Approvals: Yingyi Bu: Looks good to me, approved Jenkins: Verified; No violations found; ; Verified 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 @@ 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) { 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 -- To view, visit https://asterix-gerrit.ics.uci.edu/1932 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: Idd922bca36c7b40903c8b7abbe3386fbedd9c77b Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Murtadha Hubail <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Murtadha Hubail <[email protected]> Gerrit-Reviewer: Till Westmann <[email protected]> Gerrit-Reviewer: Yingyi Bu <[email protected]>
