def destroyPlugins()

in plugins/src/main/scala/org/apache/toree/plugins/PluginManager.scala [198:228]


  def destroyPlugins(
    plugins: Seq[Plugin],
    scopedDependencyManager: DependencyManager = DependencyManager.Empty,
    destroyOnFailure: Boolean = true
  ): Seq[PluginMethodResult] = {
    val pluginMethods = plugins.flatMap(_.destroyMethods)
    val results = invokePluginMethods(
      pluginMethods,
      scopedDependencyManager
    )

    // Perform check to remove destroyed plugins
    results.groupBy(_.pluginName).foreach { case (pluginName, g) =>
      val failures = g.flatMap(_.toTry.failed.toOption)
      val success = failures.isEmpty

      if (success) logger.debug(s"Successfully destroyed plugin $pluginName!")
      else if (destroyOnFailure) logger.debug(
        s"Failed to invoke some teardown methods, but destroyed plugin $pluginName!"
      )
      else logger.warn(s"Failed to destroy plugin $pluginName!")

      // If successful or forced, remove the plugin from our active list
      if (success || destroyOnFailure) activePlugins.remove(pluginName)

      // Log any specific failures for the plugin
      failures.foreach(ex => logger.error(pluginName, ex))
    }

    results
  }