PatchSet: Always use non-null Lists for groups
Although groups may be "missing" due to patch sets being created prior to the schema migration that added that field, the fact that these are represented in the database as null is an implementation detail. In practice we do not distinguish between empty groups and null groups, so potentially returning both of them from the API is confusing. Note that we definitely don't distinguish between these in the secondary index. Require that groups always be a non-null, and check for an empty group list to determine whether groups are "missing". This also means it's natural to use a List<String> for groups, which are naturally an ordered list. The one place where this doesn't hold is when coming out of GroupCollector, which for internal reasons needs to use a Set for deduplication. Have the few callers of that class copy the result to a list. Change-Id: I0b276e16b3ac02fd882ff1cb23d5dfd1fc7bcd20
This commit is contained in:

committed by
Edwin Kempin

parent
b3d7f7328e
commit
a714938965
@@ -17,6 +17,7 @@ package com.google.gerrit.server.schema;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -138,7 +139,7 @@ public class Schema_108 extends SchemaVersion {
|
||||
for (PatchSet.Id psId : patchSetsBySha.get(e.getKey())) {
|
||||
PatchSet ps = patchSets.get(psId);
|
||||
if (ps != null) {
|
||||
ps.setGroups(e.getValue());
|
||||
ps.setGroups(ImmutableList.copyOf(e.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user