jiacheliu3 commented on code in PR #733:
URL: https://github.com/apache/ratis/pull/733#discussion_r970511493


##########
ratis-common/src/main/java/org/apache/ratis/util/Daemon.java:
##########
@@ -17,24 +17,59 @@
  */
 package org.apache.ratis.util;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Objects;
+
 public class Daemon extends Thread {
+  static final Logger LOG = LoggerFactory.getLogger(Daemon.class);
+  public static final Thread.UncaughtExceptionHandler LOG_EXCEPTION =
+      (t, e) -> LOG.error(t.getName() + " threw an uncaught exception", e);
+
   {
     setDaemon(true);
   }
 
-  /** Construct a daemon thread. */
-  public Daemon() {
-    super();
+  /** Construct a daemon thread with flexible arguments. */
+  protected Daemon(Builder builder) {
+    super(builder.runnable);
+    setName(builder.name);
+    if (builder.uncaughtExceptionHandler != null) {
+      setUncaughtExceptionHandler(builder.uncaughtExceptionHandler);
+    }
   }
 
-  /** Construct a daemon thread with the given runnable. */
-  public Daemon(Runnable runnable) {
-    this(runnable, runnable.toString());
+  /** @return a {@link Builder}. */
+  // TODO(jiacheng): For exceptions that should crash the server, apply a 
correct UncaughtExceptionHandler

Review Comment:
   Moved to #747 and this TODO has been resolved.



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