Browse Source

[TEST] Fix GetUserPrivilegesResponse#Indices(StreamInput) constr

Closes #34631
Albert Zaharovits 7 years ago
parent
commit
aeb3cda585

+ 3 - 2
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponse.java

@@ -132,8 +132,9 @@ public final class GetUserPrivilegesResponse extends ActionResponse {
         }
 
         public Indices(StreamInput in) throws IOException {
-            indices = Collections.unmodifiableSet(in.readSet(StreamInput::readString));
-            privileges = Collections.unmodifiableSet(in.readSet(StreamInput::readString));
+            // The use of TreeSet is to provide a consistent order that can be relied upon in tests
+            indices = Collections.unmodifiableSet(new TreeSet<>(in.readSet(StreamInput::readString)));
+            privileges = Collections.unmodifiableSet(new TreeSet<>(in.readSet(StreamInput::readString)));
             fieldSecurity = Collections.unmodifiableSet(in.readSet(input -> {
                 final String[] grant = input.readOptionalStringArray();
                 final String[] exclude = input.readOptionalStringArray();