From bd91603f6df253385d4466eef9e1b0b714d27168 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Wed, 20 Jul 2016 19:45:10 +0200 Subject: [PATCH] Sort plugins in list x-pack extensions command Fix tests that rely on deterministic order. Original commit: elastic/x-pack-elasticsearch@324b0db51427413aef89cc3051676735b86d3494 --- .../extensions/ListXPackExtensionCommand.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java index c9c81828cb7..622e93434d2 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java @@ -16,6 +16,9 @@ import java.io.IOException; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.Map; import static org.elasticsearch.cli.Terminal.Verbosity.VERBOSE; @@ -37,14 +40,19 @@ class ListXPackExtensionCommand extends SettingCommand { throw new IOException("Extensions directory missing: " + resolveXPackExtensionsFile(env)); } terminal.println(VERBOSE, "XPack Extensions directory: " + resolveXPackExtensionsFile(env)); - try (DirectoryStream stream = Files.newDirectoryStream(resolveXPackExtensionsFile(env))) { - for (Path extension : stream) { - terminal.println(extension.getFileName().toString()); - XPackExtensionInfo info = - XPackExtensionInfo.readFromProperties(extension); - terminal.println(VERBOSE, info.toString()); + final List extensions = new ArrayList<>(); + try (DirectoryStream paths = Files.newDirectoryStream(resolveXPackExtensionsFile(env))) { + for (Path extension : paths) { + extensions.add(extension); } } + Collections.sort(extensions); + for (final Path extension : extensions) { + terminal.println(extension.getFileName().toString()); + XPackExtensionInfo info = + XPackExtensionInfo.readFromProperties(extension); + terminal.println(VERBOSE, info.toString()); + } } }