Skip to content

Commit

Permalink
WFLY-1323 Treat extension add ModuleNotFoundException differently fro…
Browse files Browse the repository at this point in the history
…m other types of ModuleLoadException
  • Loading branch information
bstansberry authored and jaikiran committed May 9, 2013
1 parent ca63da1 commit 453fc2b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import org.jboss.logging.annotations.MessageBundle;
import org.jboss.logging.annotations.Param;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.modules.ModuleNotFoundException;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartException;

Expand Down Expand Up @@ -2648,4 +2650,10 @@ public interface ControllerMessages {
@Message(id = 13452, value = "Legacy extension '%s' is not supported on servers running this version. The extension " +
"is only supported for use by hosts running a previous release in a mixed-version managed domain")
String unsupportedLegacyExtension(String extensionName);

@Message(id = 13453, value = "Extension module %s not found")
OperationFailedException extensionModuleNotFound(@Cause ModuleNotFoundException cause, String module);

@Message(id = 13454, value = "Failed to load Extension module %s")
RuntimeException extensionModuleLoadingFailure(@Cause ModuleLoadException cause, String module);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;

import org.jboss.as.controller.ControllerMessages;
import org.jboss.as.controller.Extension;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
Expand All @@ -30,6 +31,7 @@
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.modules.ModuleNotFoundException;

/**
* Base handler for the extension resource add operation.
Expand All @@ -49,7 +51,7 @@ public class ExtensionAddHandler implements OperationStepHandler {
* Create the AbstractAddExtensionHandler
* @param extensionRegistry registry for extensions
* @param parallelBoot {@code true} is parallel initialization of extensions is in progress; {@code false} if not
* @param slaveHC
* @param slaveHC {@code true} if this handler will execute in a slave HostController
*/
public ExtensionAddHandler(final ExtensionRegistry extensionRegistry, final boolean parallelBoot, boolean standalone, boolean slaveHC) {
assert extensionRegistry != null : "extensionRegistry is null";
Expand Down Expand Up @@ -97,8 +99,14 @@ void initializeExtension(String module) throws OperationFailedException {
SecurityActions.setThreadContextClassLoader(oldTccl);
}
}
} catch (ModuleNotFoundException e) {
// Treat this as a user mistake, e.g. incorrect module name.
// Throw OFE so post-boot it only gets logged at DEBUG.
throw ControllerMessages.MESSAGES.extensionModuleNotFound(e, module);
} catch (ModuleLoadException e) {
throw new OperationFailedException(new ModelNode().set(e.toString()));
// The module is there but can't be loaded. Treat this as an internal problem.
// Throw a runtime exception so it always gets logged at ERROR in the server log with stack trace details.
throw ControllerMessages.MESSAGES.extensionModuleLoadingFailure(e, module);
}
}

Expand Down

0 comments on commit 453fc2b

Please sign in to comment.