Add finals to RemovePluginCommand
This commit marks the RemovePluginCommand class as final, and marks some local variables as final too.
This commit is contained in:
parent
e081b2b2e8
commit
ab86660c65
|
@ -43,7 +43,7 @@ import static org.elasticsearch.cli.Terminal.Verbosity.VERBOSE;
|
||||||
/**
|
/**
|
||||||
* A command for the plugin cli to remove a plugin from elasticsearch.
|
* A command for the plugin cli to remove a plugin from elasticsearch.
|
||||||
*/
|
*/
|
||||||
class RemovePluginCommand extends SettingCommand {
|
final class RemovePluginCommand extends SettingCommand {
|
||||||
|
|
||||||
private final OptionSpec<String> arguments;
|
private final OptionSpec<String> arguments;
|
||||||
|
|
||||||
|
@ -64,16 +64,16 @@ class RemovePluginCommand extends SettingCommand {
|
||||||
|
|
||||||
terminal.println("-> Removing " + Strings.coalesceToEmpty(pluginName) + "...");
|
terminal.println("-> Removing " + Strings.coalesceToEmpty(pluginName) + "...");
|
||||||
|
|
||||||
Path pluginDir = env.pluginsFile().resolve(pluginName);
|
final Path pluginDir = env.pluginsFile().resolve(pluginName);
|
||||||
if (Files.exists(pluginDir) == false) {
|
if (Files.exists(pluginDir) == false) {
|
||||||
throw new UserException(
|
throw new UserException(
|
||||||
ExitCodes.USAGE,
|
ExitCodes.USAGE,
|
||||||
"plugin " + pluginName + " not found; run 'elasticsearch-plugin list' to get list of installed plugins");
|
"plugin " + pluginName + " not found; run 'elasticsearch-plugin list' to get list of installed plugins");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Path> pluginPaths = new ArrayList<>();
|
final List<Path> pluginPaths = new ArrayList<>();
|
||||||
|
|
||||||
Path pluginBinDir = env.binFile().resolve(pluginName);
|
final Path pluginBinDir = env.binFile().resolve(pluginName);
|
||||||
if (Files.exists(pluginBinDir)) {
|
if (Files.exists(pluginBinDir)) {
|
||||||
if (Files.isDirectory(pluginBinDir) == false) {
|
if (Files.isDirectory(pluginBinDir) == false) {
|
||||||
throw new UserException(ExitCodes.IO_ERROR, "Bin dir for " + pluginName + " is not a directory");
|
throw new UserException(ExitCodes.IO_ERROR, "Bin dir for " + pluginName + " is not a directory");
|
||||||
|
@ -83,7 +83,7 @@ class RemovePluginCommand extends SettingCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
terminal.println(VERBOSE, "Removing: " + pluginDir);
|
terminal.println(VERBOSE, "Removing: " + pluginDir);
|
||||||
Path tmpPluginDir = env.pluginsFile().resolve(".removing-" + pluginName);
|
final Path tmpPluginDir = env.pluginsFile().resolve(".removing-" + pluginName);
|
||||||
Files.move(pluginDir, tmpPluginDir, StandardCopyOption.ATOMIC_MOVE);
|
Files.move(pluginDir, tmpPluginDir, StandardCopyOption.ATOMIC_MOVE);
|
||||||
pluginPaths.add(tmpPluginDir);
|
pluginPaths.add(tmpPluginDir);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue