This is an automated email from the ASF dual-hosted git repository. ctubbsii pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
commit ece553a3ef0f47ef321eb4541ba220d22b5f796a Author: Christopher Tubbs <ctubb...@apache.org> AuthorDate: Mon Jan 31 03:23:58 2022 -0500 Remove unused priority in NamedRunnable Reduce complexity of thread management code by removing an unused priority in NamedRunnable --- .../accumulo/core/util/threads/NamedRunnable.java | 13 +------------ .../org/apache/accumulo/core/util/threads/Threads.java | 17 +---------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/util/threads/NamedRunnable.java b/core/src/main/java/org/apache/accumulo/core/util/threads/NamedRunnable.java index 64ee371..64c2b62 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/threads/NamedRunnable.java +++ b/core/src/main/java/org/apache/accumulo/core/util/threads/NamedRunnable.java @@ -18,8 +18,6 @@ */ package org.apache.accumulo.core.util.threads; -import java.util.OptionalInt; - /** * Runnable implementation that has a name and priority. Used by the NamedThreadFactory when * creating new Threads @@ -27,16 +25,10 @@ import java.util.OptionalInt; class NamedRunnable implements Runnable { private final String name; - private final OptionalInt priority; private final Runnable r; NamedRunnable(String name, Runnable r) { - this(name, OptionalInt.empty(), r); - } - - NamedRunnable(String name, OptionalInt priority, Runnable r) { this.name = name; - this.priority = priority; this.r = r; } @@ -44,10 +36,7 @@ class NamedRunnable implements Runnable { return name; } - public OptionalInt getPriority() { - return priority; - } - + @Override public void run() { r.run(); } diff --git a/core/src/main/java/org/apache/accumulo/core/util/threads/Threads.java b/core/src/main/java/org/apache/accumulo/core/util/threads/Threads.java index 3045176..2a05a4c 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/threads/Threads.java +++ b/core/src/main/java/org/apache/accumulo/core/util/threads/Threads.java @@ -29,10 +29,6 @@ public class Threads { return new NamedRunnable(name, r); } - public static Runnable createNamedRunnable(String name, OptionalInt priority, Runnable r) { - return new NamedRunnable(name, priority, r); - } - private static final UncaughtExceptionHandler UEH = new AccumuloUncaughtExceptionHandler(); public static Thread createThread(String name, Runnable r) { @@ -41,18 +37,7 @@ public class Threads { public static Thread createThread(String name, OptionalInt priority, Runnable r) { Thread thread = new Thread(Context.current().wrap(r), name); - boolean prioritySet = false; - if (r instanceof NamedRunnable) { - NamedRunnable nr = (NamedRunnable) r; - if (nr.getPriority().isPresent()) { - thread.setPriority(nr.getPriority().getAsInt()); - prioritySet = true; - } - } - // Don't override priority set in NamedRunnable, if set - if (priority.isPresent() && !prioritySet) { - thread.setPriority(priority.getAsInt()); - } + priority.ifPresent(thread::setPriority); thread.setDaemon(true); thread.setUncaughtExceptionHandler(UEH); return thread;