-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NU-2048] Fix for invalid classloader used for resources in K8sDeploy…
…mentManager (#7592)
- Loading branch information
Showing
16 changed files
with
114 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ui/process/processingtype/loader/DeploymentManagerProviderCorrectClassloaderHandler.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package pl.touk.nussknacker.ui.process.processingtype.loader | ||
|
||
import cats.data.ValidatedNel | ||
import com.typesafe.config.Config | ||
import pl.touk.nussknacker.engine.api.component.ScenarioPropertyConfig | ||
import pl.touk.nussknacker.engine.{ | ||
BaseModelData, | ||
CustomProcessValidator, | ||
DeploymentManagerDependencies, | ||
DeploymentManagerProvider, | ||
MetaDataInitializer | ||
} | ||
import pl.touk.nussknacker.engine.api.deployment.DeploymentManager | ||
import pl.touk.nussknacker.engine.deployment.EngineSetupName | ||
import pl.touk.nussknacker.engine.util.ThreadUtils | ||
import pl.touk.nussknacker.engine.util.loader.DeploymentManagersClassLoader | ||
|
||
import scala.concurrent.duration.FiniteDuration | ||
|
||
// We wrap DeploymentManagerProvider with this handler to make sure that every method execution will have the correct | ||
// context classloader pinned. It is especially important when some logic around java resources is invoked. | ||
// See for example Source.fromResource, ConfigFactory.parseResources etc. | ||
// Warning! This solution won't work for lazy loaded resources because for them, context classloader will be different. | ||
private[loader] class DeploymentManagerProviderCorrectClassloaderHandler( | ||
delegate: DeploymentManagerProvider, | ||
deploymentManagersClassLoader: DeploymentManagersClassLoader | ||
) extends DeploymentManagerProvider { | ||
|
||
override def name: String = ThreadUtils.withThisAsContextClassLoader(deploymentManagersClassLoader) { delegate.name } | ||
|
||
override def createDeploymentManager( | ||
modelData: BaseModelData, | ||
dependencies: DeploymentManagerDependencies, | ||
deploymentConfig: Config, | ||
scenarioStateCacheTTL: Option[FiniteDuration] | ||
): ValidatedNel[String, DeploymentManager] = { | ||
ThreadUtils.withThisAsContextClassLoader(deploymentManagersClassLoader) { | ||
delegate.createDeploymentManager(modelData, dependencies, deploymentConfig, scenarioStateCacheTTL) | ||
} | ||
} | ||
|
||
override def metaDataInitializer(config: Config): MetaDataInitializer = | ||
ThreadUtils.withThisAsContextClassLoader(deploymentManagersClassLoader) { delegate.metaDataInitializer(config) } | ||
|
||
override def scenarioPropertiesConfig(config: Config): Map[String, ScenarioPropertyConfig] = | ||
ThreadUtils.withThisAsContextClassLoader(deploymentManagersClassLoader) { | ||
delegate.scenarioPropertiesConfig(config) | ||
} | ||
|
||
override def additionalValidators(config: Config): List[CustomProcessValidator] = | ||
ThreadUtils.withThisAsContextClassLoader(deploymentManagersClassLoader) { delegate.additionalValidators(config) } | ||
|
||
override def defaultEngineSetupName: EngineSetupName = | ||
ThreadUtils.withThisAsContextClassLoader(deploymentManagersClassLoader) { delegate.defaultEngineSetupName } | ||
|
||
override def engineSetupIdentity(config: Config): Any = | ||
ThreadUtils.withThisAsContextClassLoader(deploymentManagersClassLoader) { delegate.engineSetupIdentity(config) } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters