From 0562fc1c7378be67b571bb142489272a6b1b3814 Mon Sep 17 00:00:00 2001 From: Sebastien Premont-Tendland Date: Mon, 2 Mar 2020 14:33:33 -0500 Subject: Fix kotlin cache lazy loading When USE_SCRIPT_COMPILATION_CACHE is set to false the classLoader is closed after the class is instantiated. This is causing an issue when lazy loading is happening during the script execution. Lazy loading occurs when a suspendible function returning something is called from "processNB", kotlin will create a second class that will be loaded during execution (needs to be in the classpath during execution). Issue-ID: CCSDK-2150 Signed-off-by: Sebastien Premont-Tendland Change-Id: I64780287352d762325662e0e5d5b94038dedee7f --- .../services/execution/ComponentFunctionScriptingService.kt | 6 ++++++ .../services/execution/ComponentScriptExecutor.kt | 2 ++ 2 files changed, 8 insertions(+) (limited to 'ms/blueprintsprocessor/modules/services/execution-service') diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt index 4c7d5d0ec..34b18091f 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt @@ -101,4 +101,10 @@ class ComponentFunctionScriptingService( } return scriptComponent } + + suspend fun cleanupInstance(bluePrintContext: BluePrintContext, scriptType: String) { + if (scriptType == BluePrintConstants.SCRIPT_KOTLIN) { + BluePrintScriptsServiceImpl().cleanupInstance(bluePrintContext.rootPath) + } + } } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt index 09eee6717..2a63297be 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt @@ -60,6 +60,8 @@ open class ComponentScriptExecutor(private var componentFunctionScriptingService // Handles both script processing and error handling scriptComponentFunction.executeScript(executionServiceInput) + + componentFunctionScriptingService.cleanupInstance(bluePrintRuntimeService.bluePrintContext(), scriptType) } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { -- cgit 1.2.3-korg