halo-dev / halo

强大易用的开源建站工具。
https://www.halo.run
GNU General Public License v3.0
33.24k stars 9.59k forks source link

插件停止生命周期中Scheme卸载问题导致升级错误 #5243

Closed guqing closed 7 months ago

guqing commented 7 months ago

系统信息

使用的哪种方式运行?

Docker

在线站点地址

https://guqing.io

发生了什么?

在插件的停止(stop)生命周期中,尝试通过 Scheme.buildFromType 方法构建 Scheme 并使用 schemeManager.unregister 进行清理。但是,这种方式无法正确地从 SchemeManager 中移除相应的 scheme,导致在升级插件时出现 `indexer 已存在的错误。问题代码段如下:

public void stop() {
        schemeManager.unregister(Scheme.buildFromType(AuthorizedClient.class));
        schemeManager.unregister(Scheme.buildFromType(Oauth2ClientRegistration.class));
 }

需要确保 Scheme 的 equals 和 hashCode 方法是否正确。

参考: Stop life cycle method in oauth2

关联 issue: #5237

相关日志输出

No response

附加信息

/kind bug /area core /milestone 2.12.x

JohnNiang commented 7 months ago

建议在 https://github.com/halo-dev/halo/issues/5237 下直接评论即可,无需创建新的 Issue。

guqing commented 7 months ago

/assign