Shutdown okhttp on plugin disable (#3347)

This commit is contained in:
Luck 2022-03-23 20:15:03 +00:00
parent eece15d415
commit 5647b2e5c6
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -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();