Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.x: fix periodic scheduler purging config not honored #5441

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ private SchedulerPoolFactory() {
* Starts the purge thread if not already started.
*/
public static void start() {
if (!PURGE_ENABLED) {
return;
}
for (;;) {
ScheduledExecutorService curr = PURGE_THREAD.get();
if (curr != null && !curr.isShutdown()) {
Expand All @@ -78,7 +81,10 @@ public static void start() {
* Stops the purge thread.
*/
public static void shutdown() {
PURGE_THREAD.get().shutdownNow();
ScheduledExecutorService exec = PURGE_THREAD.get();
if (exec != null) {
exec.shutdownNow();
}
POOLS.clear();
}

Expand All @@ -90,10 +96,10 @@ public static void shutdown() {

if (properties.containsKey(PURGE_ENABLED_KEY)) {
purgeEnable = Boolean.getBoolean(PURGE_ENABLED_KEY);
}

if (purgeEnable && properties.containsKey(PURGE_PERIOD_SECONDS_KEY)) {
purgePeriod = Integer.getInteger(PURGE_PERIOD_SECONDS_KEY, purgePeriod);
}
if (purgeEnable && properties.containsKey(PURGE_PERIOD_SECONDS_KEY)) {
purgePeriod = Integer.getInteger(PURGE_PERIOD_SECONDS_KEY, purgePeriod);
}

PURGE_ENABLED = purgeEnable;
Expand All @@ -109,7 +115,7 @@ public static void shutdown() {
*/
public static ScheduledExecutorService create(ThreadFactory factory) {
final ScheduledExecutorService exec = Executors.newScheduledThreadPool(1, factory);
if (exec instanceof ScheduledThreadPoolExecutor) {
if (PURGE_ENABLED && exec instanceof ScheduledThreadPoolExecutor) {
ScheduledThreadPoolExecutor e = (ScheduledThreadPoolExecutor) exec;
POOLS.put(e, exec);
}
Expand Down