Skip to content

Commit e3678e4

Browse files
committed
Add feature flag
1 parent 9119c06 commit e3678e4

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

core/src/main/java/org/mule/runtime/core/internal/context/DefaultMuleContext.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import static org.mule.runtime.api.config.MuleRuntimeFeature.PARALLEL_FOREACH_FLATTEN_MESSAGE;
4040
import static org.mule.runtime.api.config.MuleRuntimeFeature.PUT_TRACE_ID_AND_SPAN_ID_IN_MDC;
4141
import static org.mule.runtime.api.config.MuleRuntimeFeature.RETHROW_EXCEPTIONS_IN_IDEMPOTENT_MESSAGE_VALIDATOR;
42+
import static org.mule.runtime.api.config.MuleRuntimeFeature.SEPARATE_CLASSLOADER_FOR_POLICY_ISOLATION;
4243
import static org.mule.runtime.api.config.MuleRuntimeFeature.SET_VARIABLE_WITH_NULL_VALUE;
4344
import static org.mule.runtime.api.config.MuleRuntimeFeature.START_EXTENSION_COMPONENTS_WITH_ARTIFACT_CLASSLOADER;
4445
import static org.mule.runtime.api.config.MuleRuntimeFeature.SUPPRESS_ERRORS;
@@ -343,6 +344,7 @@ public class DefaultMuleContext implements MuleContextWithRegistry, PrivilegedMu
343344
configureComputeConnectionErrorsInStats();
344345
configureToStringTransformerTransformIteratorElements();
345346
configureEnablePolicyIsolation();
347+
configureSeparateClassLoaderForPolicyIsolation();
346348
configureEntityResolverFailOnFirstErrorFeature();
347349
configureEnableProfilingService();
348350
configureSetVariableWithNullVale();
@@ -1305,6 +1307,17 @@ private static void configureEnablePolicyIsolation() {
13051307
minMuleVersion(v4_4_0));
13061308
}
13071309

1310+
/**
1311+
* Configures the {@link MuleRuntimeFeature#SEPARATE_CLASSLOADER_FOR_POLICY_ISOLATION} feature flag.
1312+
*
1313+
* @since 4.6.0
1314+
*/
1315+
private static void configureSeparateClassLoaderForPolicyIsolation() {
1316+
FeatureFlaggingRegistry featureFlaggingRegistry = FeatureFlaggingRegistry.getInstance();
1317+
featureFlaggingRegistry.registerFeatureFlag(SEPARATE_CLASSLOADER_FOR_POLICY_ISOLATION,
1318+
minMuleVersion(v4_6_0));
1319+
}
1320+
13081321
/**
13091322
* Configures the {@link MuleRuntimeFeature#ENTITY_RESOLVER_FAIL_ON_FIRST_ERROR} feature flag.
13101323
*

modules/deployment-model-impl/src/main/java/org/mule/runtime/module/deployment/impl/internal/policy/DefaultPolicyTemplateFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package org.mule.runtime.module.deployment.impl.internal.policy;
88

99
import static org.mule.runtime.api.config.MuleRuntimeFeature.ENABLE_POLICY_ISOLATION;
10+
import static org.mule.runtime.api.config.MuleRuntimeFeature.SEPARATE_CLASSLOADER_FOR_POLICY_ISOLATION;
1011
import static org.mule.runtime.api.util.Preconditions.checkArgument;
1112
import static org.mule.runtime.deployment.model.internal.DefaultRegionPluginClassLoadersFactory.getArtifactPluginId;
1213
import static org.mule.runtime.module.artifact.api.classloader.DefaultArtifactClassLoaderFilter.NULL_CLASSLOADER_FILTER;
@@ -123,11 +124,13 @@ public PolicyTemplate createArtifact(Application application, PolicyTemplateDesc
123124
ownPolicyClassLoader));
124125
}
125126

127+
// Use additional feature flag SEPARATE_CLASSLOADER_FOR_POLICY_ISOLATION,
128+
// so that we can use isolated classloader as parent classloader, only when this feature is enabled.
126129
private boolean isPolicyIsolationEnabled(PolicyTemplateDescriptor descriptor) {
127-
return isFeatureEnabled(ENABLE_POLICY_ISOLATION, descriptor);
130+
return isFeatureEnabled(ENABLE_POLICY_ISOLATION, descriptor) &&
131+
isFeatureEnabled(SEPARATE_CLASSLOADER_FOR_POLICY_ISOLATION, descriptor);
128132
}
129133

130-
//
131134
private boolean hasRequiredPlugin(PolicyTemplateDescriptor descriptor) {
132135
if (descriptor == null || descriptor.getPlugins() == null) {
133136
return false;

0 commit comments

Comments
 (0)