Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamicCommand doesn't extend CommandModule #407

Open
imagejan opened this issue Nov 17, 2020 · 0 comments
Open

DynamicCommand doesn't extend CommandModule #407

imagejan opened this issue Nov 17, 2020 · 0 comments

Comments

@imagejan
Copy link
Member

The fact that DynamicCommand extends DefaultMutableModule but not CommandModule leads to CommandService.run() returning null, as explained in the [DEBUG] output here:

/**
* A HACK to avoid {@link ClassCastException} when calling run when the
* resultant module will not be a {@link CommandModule}. This is an API design
* flaw in CommandService currently, but for now we work around it rather than
* breaking backwards API compatibility.
*/
private Future<CommandModule> validateFuture(final Future<Module> future,
final CommandInfo info)
{
try {
final Class<?> commandClass = info.loadDelegateClass();
if (Module.class.isAssignableFrom(commandClass)) {
log.debug("The command '" + info.getIdentifier() +
"' extends Module directly. Due to a design flaw in the " +
"CommandService API, the result cannot be coerced to a " +
"Future<CommandModule>, so null will be returned instead. " +
"If you need the resulting module, please instead call " +
"moduleService.run(commandService.getCommand(commandClass), ...).");
return null;

So the workaround is to get the CommandInfo and call ModuleService#run() on it to get the Future<Module>... but is there any chance to make it extend CommandModule but still implement the required interface MutableModule without breaking backwards compatibility?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant