Uploaded image for project: 'Common Controller SDK'
  1. Common Controller SDK
  2. CCSDK-2150

Kotlin execution fail with lazy class loading

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Medium Medium
    • Frankfurt Release
    • Frankfurt Release
    • cds
    • None

      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).

       

      Here's a sample script reproducing the error

      package cba.RuntimeCBA
      
      import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
      import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
      import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
      import org.slf4j.LoggerFactory
      
      open class RResolution : ResourceAssignmentProcessor() {
      
          private val log = LoggerFactory.getLogger(RResolution::class.java)!!
      
      
          override fun getName(): String {
              return "RResolution"
          }
      
          override suspend fun processNB(resourceAssignment: ResourceAssignment) {
              log.info("Start resolving RResolution")
      
              // Set resulting value
              val retValue = getRetsolvedValue(resourceAssignment)
              ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, retValue)
          }
      
          suspend fun getResolvedValue(resourceAssignment: ResourceAssignment): String {
            return "resolved value 8"
          }
      
          override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
              log.info("Recovering RResolution")
              // Nothing to do at this point
          }
      }
      

            spremont spremont
            spremont spremont
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: