Skip to content

Commit

Permalink
Correct removeExtensionFromCache.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlakde authored Nov 5, 2024
1 parent a8cfeaa commit f05cd53
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ private void publishIntoCache(KVPair<Extension, File> result, ExtensionConfig ex
if (!isNullOrEmpty(extension.getInitClassName())) {
try {
Class<?> clz = loader.loadClass(extension.getInitClassName());
Object obj = clz.getConstructor(INaksha.class, Extension.class).newInstance(naksha, extension);
Object obj = clz.getConstructor().newInstance();
if (obj instanceof IExtensionInit initInstance) {
initInstance.close();
initInstance.init(naksha, extension);
instance = initInstance;
} else {
Expand Down Expand Up @@ -152,15 +151,12 @@ private void removeExtensionFromCache(String extensionId) {
ValueTuple valueTuple = loaderCache.get(extensionId);
if (valueTuple != null) {
IExtensionInit instance = valueTuple.getInstance();
Extension extension = valueTuple.getExtension();
final String extensionIdWithEnv = extension.getEnv() + ":" + extension.getId();

if (instance != null) {
try {
instance.close();
logger.info("Extension {} closed successfully.", extensionIdWithEnv);
logger.info("Extension {} closed successfully.", extensionId);
} catch (Exception e) {
logger.error("Failed to close extension {}", extensionIdWithEnv, e);
logger.error("Failed to close extension {}", extensionId, e);
}
}

Expand Down

0 comments on commit f05cd53

Please sign in to comment.