From 01a6e38c4ad43e00726f30f8bb45a56c5bce4fbe Mon Sep 17 00:00:00 2001 From: cssxsh Date: Sat, 3 Sep 2022 05:33:17 +0800 Subject: [PATCH] add: catch log --- .../mirai/debug/command/DebugCommands.kt | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/io/github/gnuf0rce/mirai/debug/command/DebugCommands.kt b/src/main/kotlin/io/github/gnuf0rce/mirai/debug/command/DebugCommands.kt index 8c0a299..c0d40d3 100644 --- a/src/main/kotlin/io/github/gnuf0rce/mirai/debug/command/DebugCommands.kt +++ b/src/main/kotlin/io/github/gnuf0rce/mirai/debug/command/DebugCommands.kt @@ -268,25 +268,29 @@ object DebugCommands { val cache = loader::class.java.getDeclaredField("pluginFileToInstanceMap") .apply { isAccessible = true } .get(loader) as MutableMap - val permissions = PermissionService.INSTANCE.javaClass.getDeclaredField("permissions") - .apply { isAccessible = true } - .get(PermissionService.INSTANCE) as MutableMap<*, *> PluginManager.disablePlugin(plugin = plugin) try { plugin.cancel() - } catch (_: Exception) { - // + } catch (cause: Exception) { + logger.warning({ "jvm plugin $id cancel throw exception." }, cause) } plugins.remove(plugin) try { + val permissions = PermissionService.INSTANCE.javaClass.getDeclaredField("permissions") + .apply { isAccessible = true } + .get(PermissionService.INSTANCE) as MutableMap<*, *> permissions.remove(plugin.parentPermission.id) permissions.remove(plugin.parentPermission.id.run { "$namespace.$name" }) - } catch (_: Exception) { - // + } catch (cause: Exception) { + logger.warning({ "jvm plugin $id permission remove exception." }, cause) } - runInterruptible(Dispatchers.IO) { - classLoader.close() + try { + runInterruptible(Dispatchers.IO) { + classLoader.close() + } + } catch (cause: Exception) { + logger.warning({ "jvm plugin $id class loader close exception." }, cause) } cache.remove(jar) loader.classLoaders.remove(classLoader)