From f4d9ed1660864960b524382fbd2b67cd8402e1ec Mon Sep 17 00:00:00 2001 From: LankyDan Date: Thu, 18 Jul 2019 16:16:59 +0100 Subject: [PATCH] Add missing change to `RunShellCommand` that was not included in backport When backport the `CheckpointDumper` change, the code in `RunShellCommand` was not changed correctly. This led to shell not listing all available commands. They were still available to execute but were not visible. --- .../net/corda/node/shell/RunShellCommand.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/node/src/main/java/net/corda/node/shell/RunShellCommand.java b/node/src/main/java/net/corda/node/shell/RunShellCommand.java index 2e20d06426..04a3fa58f2 100644 --- a/node/src/main/java/net/corda/node/shell/RunShellCommand.java +++ b/node/src/main/java/net/corda/node/shell/RunShellCommand.java @@ -2,6 +2,7 @@ package net.corda.node.shell; import net.corda.client.jackson.StringToMethodCallParser; import net.corda.core.internal.messaging.InternalCordaRPCOps; +import net.corda.core.messaging.CordaRPCOps; import org.crsh.cli.Argument; import org.crsh.cli.Command; import org.crsh.cli.Man; @@ -26,21 +27,30 @@ public class RunShellCommand extends InteractiveShellCommand { InvocationContext context, @Usage("The command to run") @Argument(unquote = false) List command ) { - StringToMethodCallParser parser = new StringToMethodCallParser<>(InternalCordaRPCOps.class, objectMapper()); if (command == null) { - emitHelp(context, parser); + emitHelp(context); return null; } return InteractiveShell.runRPCFromString(command, out, context, ops()); } - private void emitHelp(InvocationContext context, StringToMethodCallParser parser) { + private void emitHelp(InvocationContext context) { + // to handle the lack of working inheritance in [StringToMethodCallParser] two parsers are used + StringToMethodCallParser cordaRpcOpsParser = + new StringToMethodCallParser<>( + CordaRPCOps.class, objectMapper()); + StringToMethodCallParser internalCordaRpcOpsParser = + new StringToMethodCallParser<>( + InternalCordaRPCOps.class, objectMapper()); // Sends data down the pipeline about what commands are available. CRaSH will render it nicely. // Each element we emit is a map of column -> content. - Set> entries = parser.getAvailableCommands().entrySet(); - ArrayList> entryList = new ArrayList<>(entries); + Set> entries = cordaRpcOpsParser.getAvailableCommands().entrySet(); + Set> internalEntries = internalCordaRpcOpsParser.getAvailableCommands().entrySet(); + Set> entrySet = new HashSet<>(entries); + entrySet.addAll(internalEntries); + List> entryList = new ArrayList<>(entrySet); entryList.sort(Comparator.comparing(Map.Entry::getKey)); for (Map.Entry entry : entryList) { // Skip these entries as they aren't really interesting for the user.