From d6eec74273a4cee9edce548e726af75734096a19 Mon Sep 17 00:00:00 2001 From: belugabehr <12578579+belugabehr@users.noreply.github.com> Date: Tue, 10 Dec 2019 17:20:11 -0500 Subject: [PATCH] HBASE-23556: Minor ChoreService Cleanup (#927) --- .../org/apache/hadoop/hbase/ChoreService.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java index 0ad52b28b33..9dbb307df40 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java @@ -173,9 +173,7 @@ public class ChoreService implements ChoreServicer { * @param chore The Chore to be rescheduled. If the chore is not scheduled with this ChoreService * yet then this call is equivalent to a call to scheduleChore. */ - private synchronized void rescheduleChore(ScheduledChore chore) { - if (chore == null) return; - + private void rescheduleChore(ScheduledChore chore) { if (scheduledChores.containsKey(chore)) { ScheduledFuture future = scheduledChores.get(chore); future.cancel(false); @@ -216,12 +214,11 @@ public class ChoreService implements ChoreServicer { @InterfaceAudience.Private @Override public synchronized boolean triggerNow(ScheduledChore chore) { - if (chore == null) { - return false; - } else { + if (chore != null) { rescheduleChore(chore); return true; } + return false; } /** @@ -352,17 +349,14 @@ public class ChoreService implements ChoreServicer { } private void cancelAllChores(final boolean mayInterruptIfRunning) { - ArrayList choresToCancel = new ArrayList<>(scheduledChores.keySet().size()); // Build list of chores to cancel so we can iterate through a set that won't change // as chores are cancelled. If we tried to cancel each chore while iterating through // keySet the results would be undefined because the keySet would be changing - for (ScheduledChore chore : scheduledChores.keySet()) { - choresToCancel.add(chore); - } + ArrayList choresToCancel = new ArrayList<>(scheduledChores.keySet()); + for (ScheduledChore chore : choresToCancel) { cancelChore(chore, mayInterruptIfRunning); } - choresToCancel.clear(); } /**