keith-turner commented on a change in pull request #409: ACCUMULO-4791 fix
setshelliter usage
URL: https://github.com/apache/accumulo/pull/409#discussion_r178285864
##########
File path:
shell/src/main/java/org/apache/accumulo/shell/commands/SetIterCommand.java
##########
@@ -81,10 +86,32 @@ public int execute(final String fullCommand, final
CommandLine cl, final Shell s
classname = ReqVisFilter.class.getName();
}
- ClassLoader classloader = shellState.getClassLoader(cl, shellState);
-
- // Get the iterator options, with potentially a name provided by the
OptionDescriber impl or through user input
- String configuredName = setUpOptions(classloader, shellState.getReader(),
classname, options);
+ // ACCUMULO-4791: The SetIterCommand class as well as methods within the
Shell.java class all
+ // require that a table or namespace be provided or otherwise they will
not execute. But the
+ // setShellIter command does not require either of these values. In order
to get around
+ // this requirement we will check to see if a profile name has been
provided (indicating that
+ // we are setting a shell iterator). If so, temporarily set the table
state to an
+ // existing table such as accumulo.metadata. This allows the command to
complete successfully.
+ // After completion reassign the table to its original value and continue.
+ String currentTableName = null;
+ String tmpTable = null;
+ String configuredName;
+ try {
+ if (profileOpt != null &&
StringUtils.isBlank(shellState.getTableName())) {
+ currentTableName = shellState.getTableName();
+ tmpTable = "accumulo.metadata";
+ shellState.setTableName(tmpTable);
+ tables = cl.hasOption(OptUtil.tableOpt().getOpt()) ||
!shellState.getTableName().isEmpty();
+ }
+ ClassLoader classloader = shellState.getClassLoader(cl, shellState);
+ // Get the iterator options, with potentially a name provided by the
OptionDescriber impl or through user input
+ configuredName = setUpOptions(classloader, shellState.getReader(),
classname, options);
+ } finally {
+ // ACCUMULO-4792: reset table name and continue
+ if (profileOpt != null && tmpTable != null) {
Review comment:
This could be `if(tmpTable != null) {` making the code a bit more future
proof (for the case where tmpTable is set in a different way in future code).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services