diff --git a/core/src/main/java/org/apache/gravitino/EntityStore.java b/core/src/main/java/org/apache/gravitino/EntityStore.java index d5f49f48986..4967e21ce78 100644 --- a/core/src/main/java/org/apache/gravitino/EntityStore.java +++ b/core/src/main/java/org/apache/gravitino/EntityStore.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.Set; import java.util.function.Function; import org.apache.gravitino.Entity.EntityType; import org.apache.gravitino.exceptions.NoSuchEntityException; @@ -65,7 +66,7 @@ public interface EntityStore extends Closeable { */ default List list( Namespace namespace, Class type, EntityType entityType) throws IOException { - return list(namespace, type, entityType, Collections.emptyList()); + return list(namespace, type, entityType, Collections.emptySet()); } /** @@ -86,7 +87,7 @@ default List list( * @throws IOException if the list operation fails */ default List list( - Namespace namespace, Class type, EntityType entityType, List skippingFields) + Namespace namespace, Class type, EntityType entityType, Set skippingFields) throws IOException { throw new UnsupportedOperationException("Don't support to skip fields"); } diff --git a/core/src/main/java/org/apache/gravitino/authorization/UserGroupManager.java b/core/src/main/java/org/apache/gravitino/authorization/UserGroupManager.java index c66e0974612..4b7b4f2d8c3 100644 --- a/core/src/main/java/org/apache/gravitino/authorization/UserGroupManager.java +++ b/core/src/main/java/org/apache/gravitino/authorization/UserGroupManager.java @@ -23,7 +23,7 @@ import java.time.Instant; import java.util.Arrays; import java.util.Collections; -import java.util.List; +import java.util.Set; import org.apache.gravitino.Entity; import org.apache.gravitino.EntityAlreadyExistsException; import org.apache.gravitino.EntityStore; @@ -40,6 +40,7 @@ import org.apache.gravitino.meta.UserEntity; import org.apache.gravitino.storage.IdGenerator; import org.apache.gravitino.utils.PrincipalUtils; +import org.glassfish.jersey.internal.guava.Sets; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -116,18 +117,20 @@ User getUser(String metalake, String user) throws NoSuchUserException { } String[] listUserNames(String metalake) { - return Arrays.stream( - listUsersInternal( - metalake, Lists.newArrayList(UserEntity.ROLE_NAMES, UserEntity.ROLE_IDS))) + Set skippingFields = Sets.newHashSet(); + skippingFields.add(UserEntity.ROLE_NAMES); + skippingFields.add(UserEntity.ROLE_IDS); + + return Arrays.stream(listUsersInternal(metalake, skippingFields)) .map(User::name) .toArray(String[]::new); } User[] listUsers(String metalake) { - return listUsersInternal(metalake, Collections.emptyList()); + return listUsersInternal(metalake, Collections.emptySet()); } - private User[] listUsersInternal(String metalake, List skippingFields) { + private User[] listUsersInternal(String metalake, Set skippingFields) { try { AuthorizationUtils.checkMetalakeExists(metalake); diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java b/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java index 0c269945c00..8807bf3fa5e 100644 --- a/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java +++ b/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.Set; import java.util.function.Function; import org.apache.gravitino.Config; import org.apache.gravitino.Configs; @@ -96,7 +97,7 @@ public List list( @Override public List list( - Namespace namespace, Class type, Entity.EntityType entityType, List skippingFields) + Namespace namespace, Class type, Entity.EntityType entityType, Set skippingFields) throws IOException { return backend.list(namespace, entityType, skippingFields); }