abhishekmjain commented on code in PR #4174:
URL: https://github.com/apache/gobblin/pull/4174#discussion_r2917066734


##########
gobblin-temporal/src/main/java/org/apache/gobblin/temporal/ddm/util/NonRetryableExceptions.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.gobblin.temporal.ddm.util;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
+
+import org.apache.hadoop.hdfs.protocol.DSQuotaExceededException;
+import org.apache.hadoop.hdfs.protocol.NSQuotaExceededException;
+
+import lombok.experimental.UtilityClass;
+
+
+/**
+ * Defines exception types that should trigger immediate, non-retryable 
application failure
+ * in Temporal workflows. These represent unrecoverable conditions where 
retrying would be futile.
+ */
+@UtilityClass
+public class NonRetryableExceptions {
+
+  private static final Set<Class<? extends Exception>> EXCEPTIONS;
+  static {
+    Set<Class<? extends Exception>> exceptions = new HashSet<>();
+    exceptions.add(NSQuotaExceededException.class);
+    exceptions.add(DSQuotaExceededException.class);
+    EXCEPTIONS = Collections.unmodifiableSet(exceptions);
+  }
+
+  /**
+   * Checks whether the given throwable matches a known non-retryable 
exception type.
+   * @return an {@link Optional} containing the matched throwable if it is 
non-retryable, empty otherwise.
+   */
+  public static Optional<Throwable> matchNonRetryable(Throwable throwable) {
+    if (throwable == null) {
+      return Optional.empty();
+    }
+    for (Class<? extends Exception> exClass : EXCEPTIONS) {
+      if (exClass.isInstance(throwable)) {

Review Comment:
   we should also check for cause recursively, throwable has `getClause()` 
which returns null when there is no more underlying cause.
   
   ```  
   public synchronized Throwable getCause() {
       return (cause==this ? null : cause);
   }
   ```



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