[
https://issues.apache.org/jira/browse/GOBBLIN-2210?focusedWorklogId=976518&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-976518
]
ASF GitHub Bot logged work on GOBBLIN-2210:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 28/Jul/25 09:05
Start Date: 28/Jul/25 09:05
Worklog Time Spent: 10m
Work Description: Blazer-007 commented on code in PR #4119:
URL: https://github.com/apache/gobblin/pull/4119#discussion_r2235460111
##########
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:
Logging stacktrace will bloat the log messages, only motivation to wrap the
thread is to avoid killing of thread.
Added a log line in debug mode
Issue Time Tracking
-------------------
Worklog Id: (was: 976518)
Time Spent: 50m (was: 40m)
> 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: 50m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)