@Test @DisplayName("Test if the Twitch4J ThreadPool is closed on shutdown") public void testScheduledThreadPoolExecutorShutdown() { ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = ThreadUtils.getDefaultScheduledThreadPoolExecutor("twitch4j", 10); TwitchClient twitchClient = TwitchClientBuilder.builder() .withEnableHelix(true) .withEnableKraken(true) .withEnableChat(false) .withScheduledThreadPoolExecutor(scheduledThreadPoolExecutor) .build(); twitchClient.close(); assertTrue(scheduledThreadPoolExecutor.isShutdown(), "ThreadPool should have been closed!"); }
public void close() { log.info("Closing TwitchClient ..."); if (this.chat != null) { this.chat.close(); } if (this.pubsub != null) { this.pubsub.close(); } if (this.twitchClientHelper != null) { twitchClientHelper.close(); } if (scheduledThreadPoolExecutor.getThreadFactory() instanceof BasicThreadFactory) { BasicThreadFactory threadFactory = (BasicThreadFactory) scheduledThreadPoolExecutor.getThreadFactory(); if (threadFactory.getNamingPattern().equalsIgnoreCase("twitch4j-%d")) { scheduledThreadPoolExecutor.shutdownNow(); } } }
TwitchClient implements AutoCloseable { public void close() { log.info("Closing TwitchClient ..."); if (this.chat != null) { this.chat.close(); } if (this.pubsub != null) { this.pubsub.close(); } if (this.twitchClientHelper != null) { twitchClientHelper.close(); } if (scheduledThreadPoolExecutor.getThreadFactory() instanceof BasicThreadFactory) { BasicThreadFactory threadFactory = (BasicThreadFactory) scheduledThreadPoolExecutor.getThreadFactory(); if (threadFactory.getNamingPattern().equalsIgnoreCase("twitch4j-%d")) { scheduledThreadPoolExecutor.shutdownNow(); } } } }
TwitchClient implements AutoCloseable { public void close() { log.info("Closing TwitchClient ..."); if (this.chat != null) { this.chat.close(); } if (this.pubsub != null) { this.pubsub.close(); } if (this.twitchClientHelper != null) { twitchClientHelper.close(); } if (scheduledThreadPoolExecutor.getThreadFactory() instanceof BasicThreadFactory) { BasicThreadFactory threadFactory = (BasicThreadFactory) scheduledThreadPoolExecutor.getThreadFactory(); if (threadFactory.getNamingPattern().equalsIgnoreCase("twitch4j-%d")) { scheduledThreadPoolExecutor.shutdownNow(); } } } TwitchClient(EventManager eventManager, TwitchExtensions extensions, TwitchHelix helix, TwitchKraken kraken, TwitchMessagingInterface messagingInterface, TwitchChat chat, TwitchPubSub pubsub, TwitchGraphQL graphql, ScheduledThreadPoolExecutor threadPoolExecutor); }
TwitchClient implements AutoCloseable { public void close() { log.info("Closing TwitchClient ..."); if (this.chat != null) { this.chat.close(); } if (this.pubsub != null) { this.pubsub.close(); } if (this.twitchClientHelper != null) { twitchClientHelper.close(); } if (scheduledThreadPoolExecutor.getThreadFactory() instanceof BasicThreadFactory) { BasicThreadFactory threadFactory = (BasicThreadFactory) scheduledThreadPoolExecutor.getThreadFactory(); if (threadFactory.getNamingPattern().equalsIgnoreCase("twitch4j-%d")) { scheduledThreadPoolExecutor.shutdownNow(); } } } TwitchClient(EventManager eventManager, TwitchExtensions extensions, TwitchHelix helix, TwitchKraken kraken, TwitchMessagingInterface messagingInterface, TwitchChat chat, TwitchPubSub pubsub, TwitchGraphQL graphql, ScheduledThreadPoolExecutor threadPoolExecutor); EventManager getEventManager(); TwitchExtensions getExtensions(); TwitchHelix getHelix(); @Deprecated TwitchKraken getKraken(); @Unofficial TwitchMessagingInterface getMessagingInterface(); TwitchChat getChat(); TwitchPubSub getPubSub(); @Unofficial TwitchGraphQL getGraphQL(); ModuleLoader getModuleLoader(); TwitchClientHelper getClientHelper(); void close(); }
TwitchClient implements AutoCloseable { public void close() { log.info("Closing TwitchClient ..."); if (this.chat != null) { this.chat.close(); } if (this.pubsub != null) { this.pubsub.close(); } if (this.twitchClientHelper != null) { twitchClientHelper.close(); } if (scheduledThreadPoolExecutor.getThreadFactory() instanceof BasicThreadFactory) { BasicThreadFactory threadFactory = (BasicThreadFactory) scheduledThreadPoolExecutor.getThreadFactory(); if (threadFactory.getNamingPattern().equalsIgnoreCase("twitch4j-%d")) { scheduledThreadPoolExecutor.shutdownNow(); } } } TwitchClient(EventManager eventManager, TwitchExtensions extensions, TwitchHelix helix, TwitchKraken kraken, TwitchMessagingInterface messagingInterface, TwitchChat chat, TwitchPubSub pubsub, TwitchGraphQL graphql, ScheduledThreadPoolExecutor threadPoolExecutor); EventManager getEventManager(); TwitchExtensions getExtensions(); TwitchHelix getHelix(); @Deprecated TwitchKraken getKraken(); @Unofficial TwitchMessagingInterface getMessagingInterface(); TwitchChat getChat(); TwitchPubSub getPubSub(); @Unofficial TwitchGraphQL getGraphQL(); ModuleLoader getModuleLoader(); TwitchClientHelper getClientHelper(); void close();  }