fix: NPE when stopping the plugin after the plugin startup fails (#3580)

#### What type of PR is this?
/kind improvement
/area core
/milestone 2.4.x

#### What this PR does / why we need it:
修复插件启动失败后停止插件时出现的 NPE 问题

how to test it?
见 #3579,先使用 issue 描述步骤复现问题,在切换到此 PR 尝试相同步骤

#### Which issue(s) this PR fixes:

Fixes #3579

#### Does this PR introduce a user-facing change?
```release-note
修复插件启动失败后停止插件时出现的 NPE 问题
```
pull/3561/head
guqing 2023-03-27 16:12:12 +08:00 committed by GitHub
parent 9a00a74f06
commit 6bc712d263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -142,7 +142,9 @@ public class HaloPluginManager extends DefaultPluginManager
}
try {
log.info("Stop plugin '{}'", getPluginLabel(pluginDescriptor));
if (pluginWrapper.getPlugin() != null) {
pluginWrapper.getPlugin().stop();
}
pluginWrapper.setPluginState(PluginState.STOPPED);
// release plugin resources
releaseAdditionalResources(pluginId);
@ -304,7 +306,9 @@ public class HaloPluginManager extends DefaultPluginManager
rootApplicationContext.publishEvent(
new HaloPluginBeforeStopEvent(this, pluginWrapper));
log.info("Stop plugin '{}'", getPluginLabel(pluginWrapper.getDescriptor()));
if (pluginWrapper.getPlugin() != null) {
pluginWrapper.getPlugin().stop();
}
pluginWrapper.setPluginState(PluginState.STOPPED);
itr.remove();
releaseAdditionalResources(pluginWrapper.getPluginId());