diff --git a/server/src/main/java/com/linecorp/centraldogma/server/metadata/RepositoryMetadataDeserializer.java b/server/src/main/java/com/linecorp/centraldogma/server/metadata/RepositoryMetadataDeserializer.java index 7c3e31f89..9210db599 100644 --- a/server/src/main/java/com/linecorp/centraldogma/server/metadata/RepositoryMetadataDeserializer.java +++ b/server/src/main/java/com/linecorp/centraldogma/server/metadata/RepositoryMetadataDeserializer.java @@ -15,8 +15,6 @@ */ package com.linecorp.centraldogma.server.metadata; -import static com.google.common.collect.ImmutableMap.toImmutableMap; - import java.io.IOException; import java.util.Collection; import java.util.Map; @@ -29,6 +27,8 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; import com.linecorp.centraldogma.common.RepositoryRole; import com.linecorp.centraldogma.internal.Jackson; @@ -94,7 +94,16 @@ private static RepositoryRole repositoryRole(Collection permissions) } private static Map convert(Map> permissions) { - return permissions.entrySet().stream() - .collect(toImmutableMap(Entry::getKey, entry -> repositoryRole(entry.getValue()))); + final Builder builder = ImmutableMap.builder(); + for (Entry> entry : permissions.entrySet()) { + final Collection value = entry.getValue(); + if (!value.isEmpty()) { + final RepositoryRole repositoryRole = repositoryRole(value); + assert repositoryRole != null; + builder.put(entry.getKey(), repositoryRole); + } + } + + return builder.build(); } } diff --git a/server/src/test/java/com/linecorp/centraldogma/server/metadata/RepositoryMetadataDeserializerTest.java b/server/src/test/java/com/linecorp/centraldogma/server/metadata/RepositoryMetadataDeserializerTest.java index 4f30e5855..279bd7d4c 100644 --- a/server/src/test/java/com/linecorp/centraldogma/server/metadata/RepositoryMetadataDeserializerTest.java +++ b/server/src/test/java/com/linecorp/centraldogma/server/metadata/RepositoryMetadataDeserializerTest.java @@ -45,12 +45,14 @@ void deserializeLegacyFormat() throws Exception { " \"bar@dogma.com\": [" + " \"READ\"," + " \"WRITE\"" + - " ]" + + " ]," + + " \"emptyMember\": []" + // Will be removed " }," + " \"perTokenPermissions\": {" + " \"goodman\": [" + " \"READ\"" + - " ]" + + " ]," + + " \"emptyToken\": []" + // Will be removed " }," + " \"creation\": {" + " \"user\": \"minu.song@dogma.com\"," +