hudi-agent commented on code in PR #18371:
URL: https://github.com/apache/hudi/pull/18371#discussion_r3301823812


##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java:
##########
@@ -690,6 +691,8 @@ public boolean doMetadataTableValidation() {
     } catch (SparkException sparkException) {
       if (sparkException.getCause() instanceof HoodieValidationException) {
         throw (HoodieValidationException) sparkException.getCause();
+      } else if (ExceptionUtil.validateErrorMsg(sparkException, "cancelled 
because SparkContext was shut down")) {

Review Comment:
   🤖 nit: the magic string `"cancelled because SparkContext was shut down"` 
would be easier to find/reuse if pulled out as a private static final constant 
(e.g. `SPARK_CONTEXT_SHUTDOWN_MSG`) with a short comment on why we special-case 
it.
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-common/src/main/java/org/apache/hudi/exception/ExceptionUtil.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.hudi.exception;
+
+import org.apache.hudi.common.util.StringUtils;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Util class for exception analysis.
+ */
+public final class ExceptionUtil {
+  private ExceptionUtil() {
+  }
+
+  /**
+   * Returns true if error message is contained in any nested exception of 
provided {@link Throwable}.
+   */
+  public static boolean validateErrorMsg(@Nonnull Throwable t, String 
errorMsg) {
+    if (StringUtils.isNullOrEmpty(errorMsg)) {

Review Comment:
   🤖 nit: `validateErrorMsg` reads like an assertion/throwing validator, but it 
just does a contains-check over the cause chain. Could we rename it to 
something like `hasErrorMessage` or `containsMessageInCauseChain` so the 
predicate intent is clear at the call site?
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to