[ 
https://issues.apache.org/jira/browse/GOBBLIN-2210?focusedWorklogId=976479&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-976479
 ]

ASF GitHub Bot logged work on GOBBLIN-2210:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Jul/25 05:20
            Start Date: 28/Jul/25 05:20
    Worklog Time Spent: 10m 
      Work Description: thisisArjit commented on code in PR #4119:
URL: https://github.com/apache/gobblin/pull/4119#discussion_r2234728408


##########
gobblin-utility/src/main/java/org/apache/gobblin/util/ExecutorsUtils.java:
##########
@@ -162,6 +165,27 @@ public static Runnable loggingDecorator(Runnable runnable) 
{
     return new MDCPropagatingRunnable(runnable);
   }
 
+
+  /**
+   * Wraps a {@link Runnable} task with exception handling to ensure that
+   * any thrown exception does not terminate the thread or scheduled executor.
+   * This is useful for long-running or recurring tasks where resilience is 
critical.
+   *
+   * @param runnable the task to wrap
+   * @return a safe {@link Runnable} that logs and suppresses exceptions
+   */
+  public static Runnable safeRunnable(Runnable runnable) {
+    return () -> {
+      try {
+        runnable.run();
+      } catch (Exception exception) {
+        // Catch all exceptions to prevent the thread from dying
+        // and log the exception
+        log.error("Caught exception in runnable {}", exception.getMessage());

Review Comment:
   should we log stacktrace?





Issue Time Tracking
-------------------

    Worklog Id:     (was: 976479)
    Time Spent: 0.5h  (was: 20m)

> Add exception handling in Temporal Heartbeat Runnable
> -----------------------------------------------------
>
>                 Key: GOBBLIN-2210
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-2210
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: Vivek Rai
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to