diff --git a/src/main/scala/gitbucket/core/plugin/Plugin.scala b/src/main/scala/gitbucket/core/plugin/Plugin.scala index 4367c68..c751ad8 100644 --- a/src/main/scala/gitbucket/core/plugin/Plugin.scala +++ b/src/main/scala/gitbucket/core/plugin/Plugin.scala @@ -248,11 +248,17 @@ } /** - * This method is invoked in shutdown of plugin system. + * This method is invoked when the plugin system is shutting down. * If the plugin has any resources, release them in this method. */ def shutdown(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Unit = {} +// /** +// * This method is invoked when this plugin is uninstalled. +// * Cleanup database or any other resources in this method if necessary. +// */ +// def uninstall(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Unit = {} + /** * Helper method to get a resource from classpath. */ diff --git a/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala b/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala index a4fa0ec..802ed10 100644 --- a/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala +++ b/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala @@ -181,8 +181,13 @@ */ def uninstall(pluginId: String, context: ServletContext, settings: SystemSettings, conn: java.sql.Connection): Unit = synchronized { instance.getPlugins().find(_.pluginId == pluginId).foreach { plugin => +// try { +// plugin.pluginClass.uninstall(instance, context, settings) +// } catch { +// case e: Exception => +// logger.error(s"Error during uninstalling plugin: ${plugin.pluginJar.getName}", e) +// } shutdown(context, settings) - // TODO kick uninstall action here? plugin.pluginJar.delete() instance = new PluginRegistry() initialize(context, settings, conn) @@ -260,15 +265,15 @@ } def shutdown(context: ServletContext, settings: SystemSettings): Unit = synchronized { - instance.getPlugins().foreach { pluginInfo => + instance.getPlugins().foreach { plugin => try { - pluginInfo.pluginClass.shutdown(instance, context, settings) + plugin.pluginClass.shutdown(instance, context, settings) } catch { case e: Exception => { - logger.error(s"Error during plugin shutdown: ${pluginInfo.pluginJar.getName}", e) + logger.error(s"Error during plugin shutdown: ${plugin.pluginJar.getName}", e) } } finally { - pluginInfo.classLoader.close() + plugin.classLoader.close() } } }