From 6c9e81426bd257ca72c3192e704329b600d3d217 Mon Sep 17 00:00:00 2001 From: Kabir Khan Date: Tue, 19 Mar 2024 11:13:29 +0000 Subject: [PATCH] [WFCORE-6728] Change stability in ExtensionRegistry when reloading --- .../extension/ExtensionRegistry.java | 25 +++++++++++++------ .../as/server/ApplicationServerService.java | 2 +- .../java/org/jboss/as/server/Bootstrap.java | 15 +++++++++-- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/controller/src/main/java/org/jboss/as/controller/extension/ExtensionRegistry.java b/controller/src/main/java/org/jboss/as/controller/extension/ExtensionRegistry.java index f2853619461..00dc50e0a41 100644 --- a/controller/src/main/java/org/jboss/as/controller/extension/ExtensionRegistry.java +++ b/controller/src/main/java/org/jboss/as/controller/extension/ExtensionRegistry.java @@ -18,6 +18,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; import java.util.regex.Pattern; @@ -117,7 +118,7 @@ public static class Builder { private JmxAuthorizer authorizer = NO_OP_AUTHORIZER; private Supplier securityIdentitySupplier = Functions.constantSupplier(null); private RuntimeHostControllerInfoAccessor hostControllerInfoAccessor = RuntimeHostControllerInfoAccessor.SERVER; - private Stability stability = Stability.DEFAULT; + private AtomicReference stabilityReference = new AtomicReference<>(Stability.DEFAULT); private Builder(ProcessType processType) { this.processType = processType; @@ -183,12 +184,22 @@ public Builder withHostControllerInfoAccessor(RuntimeHostControllerInfoAccessor } /** - * Overrides the default stability level of the extension registry. - * @param stability a stability level + * Overrides the default stability level of the extension registry. This is a convenience method for + * {@link #withStabilityReference(AtomicReference)}. + * @param stability the stability level to use * @return a reference to this builder */ public Builder withStability(Stability stability) { - this.stability = stability; + return withStabilityReference(new AtomicReference<>(stability)); + } + + /** + * Overrides the default stability level of the extension registry. + * @param stabilityReference an AtomicReference containing the stability level + * @return a reference to this builder + */ + public Builder withStabilityReference(AtomicReference stabilityReference) { + this.stabilityReference = stabilityReference; return this; } @@ -209,7 +220,7 @@ public ExtensionRegistry build() { } private final ProcessType processType; - private final Stability stability; + private final AtomicReference stability; private SubsystemXmlWriterRegistry writerRegistry; private volatile PathManager pathManager; @@ -233,7 +244,7 @@ private ExtensionRegistry(Builder builder) { this.authorizer = builder.authorizer; this.securityIdentitySupplier = builder.securityIdentitySupplier; this.hostControllerInfoAccessor = builder.hostControllerInfoAccessor; - this.stability = builder.stability; + this.stability = builder.stabilityReference; } /** @@ -539,7 +550,7 @@ public TransformerRegistry getTransformerRegistry() { @Override public Stability getStability() { - return this.stability; + return this.stability.get(); } private abstract class AbstractExtensionParsingContext implements ExtensionParsingContext, AutoCloseable { diff --git a/server/src/main/java/org/jboss/as/server/ApplicationServerService.java b/server/src/main/java/org/jboss/as/server/ApplicationServerService.java index 5c577085a43..2bc23d9916d 100644 --- a/server/src/main/java/org/jboss/as/server/ApplicationServerService.java +++ b/server/src/main/java/org/jboss/as/server/ApplicationServerService.java @@ -86,7 +86,7 @@ public synchronized void start(final StartContext context) throws StartException } else { configuration = this.configuration; } - final ServerEnvironment serverEnvironment = configuration.getServerEnvironment().recalculateForReload(runningModeControl); + final ServerEnvironment serverEnvironment = configuration.getServerEnvironment(); final ProductConfig config = serverEnvironment.getProductConfig(); final String prettyVersion = config.getPrettyVersionString(); ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion); diff --git a/server/src/main/java/org/jboss/as/server/Bootstrap.java b/server/src/main/java/org/jboss/as/server/Bootstrap.java index a4288da2dd5..078f7cb5805 100644 --- a/server/src/main/java/org/jboss/as/server/Bootstrap.java +++ b/server/src/main/java/org/jboss/as/server/Bootstrap.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.concurrent.ExecutorService; +import java.util.concurrent.atomic.AtomicReference; import javax.xml.namespace.QName; @@ -23,6 +24,7 @@ import org.jboss.as.server.controller.git.GitConfigurationPersister; import org.jboss.as.controller.persistence.XmlConfigurationPersister; import org.jboss.as.server.parsing.StandaloneXml; +import org.jboss.as.version.Stability; import org.jboss.modules.Module; import org.jboss.modules.ModuleLoader; import org.jboss.msc.service.ServiceActivator; @@ -78,6 +80,8 @@ final class Configuration { private final ManagedAuditLogger auditLogger; private final DelegatingConfigurableAuthorizer authorizer; private final ManagementSecurityIdentitySupplier securityIdentitySupplier; + + private final AtomicReference stabilityReference; private ModuleLoader moduleLoader = Module.getBootModuleLoader(); private ConfigurationPersisterFactory configurationPersisterFactory; private long startTime; @@ -89,9 +93,10 @@ public Configuration(final ServerEnvironment serverEnvironment) { this.auditLogger = serverEnvironment.createAuditLogger(); this.authorizer = new DelegatingConfigurableAuthorizer(); this.securityIdentitySupplier = new ManagementSecurityIdentitySupplier(); + this.stabilityReference = new AtomicReference<>(serverEnvironment.getStability()); this.extensionRegistry = ExtensionRegistry.builder(serverEnvironment.getLaunchType().getProcessType()) .withRunningModeControl(this.runningModeControl) - .withStability(serverEnvironment.getStability()) + .withStabilityReference(this.stabilityReference) .withAuditLogger(this.auditLogger) .withAuthorizer(this.authorizer) .withSecurityIdentitySupplier(this.securityIdentitySupplier) @@ -101,13 +106,19 @@ public Configuration(final ServerEnvironment serverEnvironment) { } private Configuration(final Configuration original, ServerEnvironment serverEnvironment) { + // Updating the server environment here, will update the value this.serverEnvironment = serverEnvironment; - this.runningModeControl = original.runningModeControl; this.extensionRegistry = original.extensionRegistry; + this.runningModeControl = original.runningModeControl; this.capabilityRegistry = original.capabilityRegistry; this.auditLogger = original.auditLogger; this.authorizer = original.authorizer; this.securityIdentitySupplier = original.securityIdentitySupplier; + + // The extension registry caches the stability supplier so update its value here + this.stabilityReference = original.stabilityReference; + this.stabilityReference.set(this.serverEnvironment.getStability()); + this.moduleLoader = original.moduleLoader; this.configurationPersisterFactory = original.configurationPersisterFactory; this.startTime = original.startTime;