Skip to content

Commit

Permalink
[WFCORE-6843] Logging a WARN if a deployment's runtime name doesn't h…
Browse files Browse the repository at this point in the history
…ave an extension
  • Loading branch information
khermano committed Feb 17, 2025
1 parent 5570824 commit ac61cc4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public interface DomainControllerLogger extends BasicLogger {
*/
DomainControllerLogger HOST_CONTROLLER_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), DomainControllerLogger.class, "org.jboss.as.host.controller");

/**
* A logger with the category of {@code org.jboss.as.domain.controller.operations.deployment.warning}.
* <strong>Usage:</strong> Use this in code related to deployment's warnings
*/
DomainControllerLogger DEPLOYMENT_WARN_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), DomainControllerLogger.class, "org.jboss.as.domain.controller.operations.deployment.warning");

@LogMessage(level = Level.WARN)
@Message(id = 1, value = "Ignoring 'include' child of 'socket-binding-group' %s")
void warnIgnoringSocketBindingGroupInclude(Location location);
Expand Down Expand Up @@ -789,4 +795,8 @@ public interface DomainControllerLogger extends BasicLogger {

@Message(id = 98, value = "The following servers %s are starting; execution of remote management operations is not currently available")
OperationFailedException serverManagementUnavailableDuringBoot(String serverNames);

@LogMessage(level = Level.WARN)
@Message(id = 99, value = "Deployment '%s' has a runtime name '%s' without an extension. This may cause issues in some environments.")
void deploymentsRuntimeNameWithoutExtension(String deploymentName, String runtimeName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CONTENT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DEPLOYMENT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.domain.controller.logging.DomainControllerLogger.DEPLOYMENT_WARN_LOGGER;
import static org.jboss.as.server.controller.resources.DeploymentAttributes.CONTENT_HASH;
import static org.jboss.as.server.controller.resources.DeploymentAttributes.ENABLED;
import static org.jboss.as.server.controller.resources.DeploymentAttributes.RUNTIME_NAME_NILLABLE;
Expand Down Expand Up @@ -94,6 +95,9 @@ static void validateRuntimeNames(String deploymentName, OperationContext context
Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
ModelNode domainDeployment = root.getChild(PathElement.pathElement(DEPLOYMENT, deploymentName)).getModel();
String runtimeName = getRuntimeName(deploymentName, deployment, domainDeployment);
if (!runtimeName.contains(".")) {
DEPLOYMENT_WARN_LOGGER.deploymentsRuntimeNameWithoutExtension(deploymentName, runtimeName);
}
PathAddress sgAddress = address.subAddress(0, address.size() - 1);
Resource serverGroup = root.navigate(sgAddress);
for (Resource.ResourceEntry re : serverGroup.getChildren(DEPLOYMENT)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.jboss.as.server.controller.resources.DeploymentAttributes.PERSISTENT;
import static org.jboss.as.server.deployment.DeploymentHandlerUtils.getContents;
import static org.jboss.as.server.deployment.DeploymentHandlerUtils.getInputStream;
import static org.jboss.as.server.logging.ServerLogger.DEPLOYMENT_WARN_LOGGER;
import static org.jboss.msc.service.ServiceController.Mode.REMOVE;

import java.io.IOException;
Expand Down Expand Up @@ -142,6 +143,9 @@ public static void deploy(final OperationContext context, final ModelNode operat

context.addStep(new OperationStepHandler() {
public void execute(OperationContext context, ModelNode operation) {
if (!deploymentUnitName.contains(".")) {
DEPLOYMENT_WARN_LOGGER.deploymentsRuntimeNameWithoutExtension(managementName, deploymentUnitName);
}
final ServiceName deploymentUnitServiceName = Services.deploymentUnitName(deploymentUnitName);
final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
final ServiceController<?> deploymentController = serviceRegistry.getService(deploymentUnitServiceName);
Expand Down
10 changes: 10 additions & 0 deletions server/src/main/java/org/jboss/as/server/logging/ServerLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public interface ServerLogger extends BasicLogger {
*/
ServerLogger DEPRECATED_DEP_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ServerLogger.class, "org.jboss.as.dependency.deprecated");

/**
* A logger with the category of {@code org.jboss.as.server.deployment.warning}.
* <strong>Usage:</strong> Use this in code related to deployment's warnings
*/
ServerLogger DEPLOYMENT_WARN_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ServerLogger.class, "org.jboss.as.server.deployment.warning");

/**
* Log message for when a jboss-deployment-structure.xml file is ignored
* @param file name of the ignored file
Expand Down Expand Up @@ -1481,6 +1487,10 @@ default void suspendingServer(long timeout, TimeUnit unit) {
@Message(id = 311, value = "Cannot create a ServerEnvironment for an embedded server")
IllegalStateException cannotCreateServerEnvironment();

@LogMessage(level = Logger.Level.WARN)
@Message(id = 312, value = "Deployment '%s' has a runtime name '%s' without an extension. This may cause issues in some environments.")
void deploymentsRuntimeNameWithoutExtension(String managementName, String deploymentUnitName);

////////////////////////////////////////////////
//Messages without IDs

Expand Down

0 comments on commit ac61cc4

Please sign in to comment.