mirror of https://github.com/halo-dev/halo
Silent prompt when plugins fail to load in development mode (#2907)
#### What type of PR is this? /kind improvement /area core #### What this PR does / why we need it: 在插件开发模式下加载插件失败时不抛出异常改为静默提示 #### Which issue(s) this PR fixes: A part of #2901 #### Special notes for your reviewer: how to test it? 1. 配置 `halo.plugin.fixed-plugin-path` 为一些不合法的插件项目路径不影响 Halo 正常启动,且有错误提示 2. 配置合法路径,插件能正确启动 #### Does this PR introduce a user-facing change? ```release-note 插件开发模式下无法被加载时改为静默提示不抛出异常 ```pull/2918/head
parent
86e5366797
commit
d06078893e
|
@ -381,15 +381,9 @@ public class HaloPluginManager extends DefaultPluginManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PluginWrapper loadPluginFromPath(Path pluginPath) {
|
protected PluginWrapper loadPluginFromPath(Path pluginPath) {
|
||||||
try {
|
|
||||||
PluginWrapper pluginWrapper = super.loadPluginFromPath(pluginPath);
|
PluginWrapper pluginWrapper = super.loadPluginFromPath(pluginPath);
|
||||||
rootApplicationContext.publishEvent(new HaloPluginLoadedEvent(this, pluginWrapper));
|
rootApplicationContext.publishEvent(new HaloPluginLoadedEvent(this, pluginWrapper));
|
||||||
return pluginWrapper;
|
return pluginWrapper;
|
||||||
} catch (PluginRuntimeException e) {
|
|
||||||
// ignore this
|
|
||||||
log.warn(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removePluginComponentsCache(String pluginId) {
|
private void removePluginComponentsCache(String pluginId) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package run.halo.app.plugin;
|
package run.halo.app.plugin;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.pf4j.PluginWrapper;
|
import org.pf4j.PluginWrapper;
|
||||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
|
@ -13,6 +14,7 @@ import run.halo.app.extension.ExtensionClient;
|
||||||
* @author guqing
|
* @author guqing
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class PluginDevelopmentInitializer implements ApplicationListener<ApplicationReadyEvent> {
|
public class PluginDevelopmentInitializer implements ApplicationListener<ApplicationReadyEvent> {
|
||||||
|
|
||||||
|
@ -43,7 +45,17 @@ public class PluginDevelopmentInitializer implements ApplicationListener<Applica
|
||||||
if (idForPath(path) != null) {
|
if (idForPath(path) != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String pluginId = pluginManager.loadPlugin(path);
|
|
||||||
|
// for issue #2901
|
||||||
|
String pluginId;
|
||||||
|
|
||||||
|
try {
|
||||||
|
pluginId = pluginManager.loadPlugin(path);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn(e.getMessage(), e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
PluginWrapper pluginWrapper = pluginManager.getPlugin(pluginId);
|
PluginWrapper pluginWrapper = pluginManager.getPlugin(pluginId);
|
||||||
if (pluginWrapper == null) {
|
if (pluginWrapper == null) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue