yihua commented on code in PR #18371:
URL: https://github.com/apache/hudi/pull/18371#discussion_r3035867964


##########
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();

Review Comment:
   🤖 The string `"cancelled because SparkContext was shut down"` is an internal 
Spark message that could silently change between Spark versions (Hudi's CI 
matrix already covers 3.3 through 4.0). Have you verified the wording is stable 
across all supported Spark versions? It might also be worth checking 
`sparkException.getMessage()` directly at the top level first, before walking 
nested causes, since this particular message typically surfaces at the 
`SparkException` level itself.



##########
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)) {
+      return false;
+    }
+
+    Throwable cause = t;
+    while (cause != null) {
+      if (cause.getMessage().contains(errorMsg)) {
+        return true;

Review Comment:
   🤖 `cause.getMessage()` can return `null` when an exception is constructed 
without a message (e.g. `new RuntimeException(anotherException)`), which would 
throw an NPE here. Could you guard this with something like `cause.getMessage() 
!= null && cause.getMessage().contains(errorMsg)`?



-- 
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