数据库更新失败,插件卸载
This commit is contained in:
@@ -91,12 +91,14 @@ public class CoolPluginService {
|
|||||||
public void install(MultipartFile file, boolean force) {
|
public void install(MultipartFile file, boolean force) {
|
||||||
File jarFile = null;
|
File jarFile = null;
|
||||||
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
|
||||||
|
String key = null;
|
||||||
try {
|
try {
|
||||||
// 保存jar文件
|
// 保存jar文件
|
||||||
jarFile = saveJarFile(file);
|
jarFile = saveJarFile(file);
|
||||||
String jarFilePath = jarFile.getAbsolutePath();
|
String jarFilePath = jarFile.getAbsolutePath();
|
||||||
// 加载jar
|
// 加载jar
|
||||||
PluginJson pluginJson = dynamicJarLoaderService.install(jarFilePath, force);
|
PluginJson pluginJson = dynamicJarLoaderService.install(jarFilePath, force);
|
||||||
|
key = pluginJson.getKey();
|
||||||
// 保存插件信息入库
|
// 保存插件信息入库
|
||||||
savePluginInfo(pluginJson, jarFilePath, jarFile, force);
|
savePluginInfo(pluginJson, jarFilePath, jarFile, force);
|
||||||
// 把 ApplicationContext 对象传递打插件类中,使其在插件中也能正常使用spring bean对象
|
// 把 ApplicationContext 对象传递打插件类中,使其在插件中也能正常使用spring bean对象
|
||||||
@@ -107,11 +109,16 @@ public class CoolPluginService {
|
|||||||
CoolPreconditions.returnData(
|
CoolPreconditions.returnData(
|
||||||
new CoolPreconditions.ReturnData(1, "插件已存在,继续安装将覆盖"));
|
new CoolPreconditions.ReturnData(1, "插件已存在,继续安装将覆盖"));
|
||||||
}
|
}
|
||||||
|
if (ObjUtil.isNotEmpty(key)) {
|
||||||
|
// 报错失败,调用卸载
|
||||||
|
dynamicJarLoaderService.uninstall(key);
|
||||||
|
}
|
||||||
CoolPreconditions.alwaysThrow(persistenceException.getMessage());
|
CoolPreconditions.alwaysThrow(persistenceException.getMessage());
|
||||||
} catch (CoolException e) {
|
} catch (CoolException e) {
|
||||||
FileUtil.del(jarFile);
|
FileUtil.del(jarFile);
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
FileUtil.del(jarFile);
|
||||||
log.error("插件安装失败", e);
|
log.error("插件安装失败", e);
|
||||||
CoolPreconditions.alwaysThrow("插件安装失败", e);
|
CoolPreconditions.alwaysThrow("插件安装失败", e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user