From 27808e9e8cc8f212e896c7f8c48e406b9f06755f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 26 Feb 2018 10:24:35 +0100 Subject: [PATCH] Make PingManager use Manager.schedule() --- .../jivesoftware/smackx/ping/PingManager.java | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java index e8e66f8c5..90a548538 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java @@ -1,6 +1,6 @@ /** * - * Copyright 2012-2017 Florian Schmaus + * Copyright 2012-2018 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,6 @@ import java.util.Map; import java.util.Set; import java.util.WeakHashMap; import java.util.concurrent.CopyOnWriteArraySet; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -45,7 +43,6 @@ import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ.Type; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.XMPPError; -import org.jivesoftware.smack.util.SmackExecutorThreadFactory; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.ping.packet.Ping; @@ -112,8 +109,6 @@ public final class PingManager extends Manager { private final Set pingFailedListeners = new CopyOnWriteArraySet<>(); - private final ScheduledExecutorService executorService; - /** * The interval in seconds between pings are send to the users server. */ @@ -123,8 +118,6 @@ public final class PingManager extends Manager { private PingManager(XMPPConnection connection) { super(connection); - executorService = Executors.newSingleThreadScheduledExecutor( - new SmackExecutorThreadFactory(connection, "Ping")); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); sdm.addFeature(Ping.NAMESPACE); @@ -391,7 +384,7 @@ public final class PingManager extends Manager { int nextPingIn = pingInterval - delta; LOGGER.fine("Scheduling ServerPingTask in " + nextPingIn + " seconds (pingInterval=" + pingInterval + ", delta=" + delta + ")"); - nextAutomaticPing = executorService.schedule(pingServerRunnable, nextPingIn, TimeUnit.SECONDS); + nextAutomaticPing = schedule(pingServerRunnable, nextPingIn, TimeUnit.SECONDS); } } @@ -479,16 +472,4 @@ public final class PingManager extends Manager { } }; - @Override - protected void finalize() throws Throwable { - LOGGER.fine("finalizing PingManager: Shutting down executor service"); - try { - executorService.shutdown(); - } catch (Throwable t) { - LOGGER.log(Level.WARNING, "finalize() threw throwable", t); - } - finally { - super.finalize(); - } - } }