From 5647b2e5c6b13f685f492e49e4af83d7ffa402fa Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 23 Mar 2022 20:15:03 +0000 Subject: [PATCH] Shutdown okhttp on plugin disable (#3347) --- .../common/plugin/AbstractLuckPermsPlugin.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java index 9bb3b7c1a..e986a0dd5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java @@ -91,6 +91,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { private PermissionRegistry permissionRegistry; private LogDispatcher logDispatcher; private LuckPermsConfiguration configuration; + private OkHttpClient httpClient; private BytebinClient bytebin; private BytesocksClient bytesocks; private WebEditorStore webEditorStore; @@ -134,12 +135,12 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { this.configuration = new LuckPermsConfiguration(this, provideConfigurationAdapter()); // setup a bytebin instance - OkHttpClient httpClient = new OkHttpClient.Builder() + this.httpClient = new OkHttpClient.Builder() .callTimeout(15, TimeUnit.SECONDS) .build(); - this.bytebin = new BytebinClient(httpClient, getConfiguration().get(ConfigKeys.BYTEBIN_URL), "luckperms"); - this.bytesocks = new BytesocksClient(httpClient, getConfiguration().get(ConfigKeys.BYTESOCKS_HOST), "luckperms/editor"); + this.bytebin = new BytebinClient(this.httpClient, getConfiguration().get(ConfigKeys.BYTEBIN_URL), "luckperms"); + this.bytesocks = new BytesocksClient(this.httpClient, getConfiguration().get(ConfigKeys.BYTESOCKS_HOST), "luckperms/editor"); this.webEditorStore = new WebEditorStore(this); // init translation repo and update bundle files @@ -273,6 +274,10 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { // shutdown async executor pool getBootstrap().getScheduler().shutdownExecutor(); + // shutdown okhttp + this.httpClient.dispatcher().executorService().shutdown(); + this.httpClient.connectionPool().evictAll(); + // close classpath appender getBootstrap().getClassPathAppender().close();