HADOOP-17505. public interface GroupMappingServiceProvider needs default impl for getGroupsSet() (#2661). Contributed by Vinayakumar B.

This commit is contained in:
Vinayakumar B 2021-04-22 01:02:03 +05:30 committed by GitHub
parent 5221322b96
commit c4c0683dff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.security; package org.apache.hadoop.security;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -61,5 +62,8 @@ public interface GroupMappingServiceProvider {
* @return set of group memberships of user * @return set of group memberships of user
* @throws IOException * @throws IOException
*/ */
Set<String> getGroupsSet(String user) throws IOException; default Set<String> getGroupsSet(String user) throws IOException {
//Override to form the set directly to avoid another conversion
return new LinkedHashSet<>(getGroups(user));
}
} }