Prefer subtypes of Multimap

Guava team recommends using the subinterfaces of Multimap, for the
same reasons they recommend using Set and List rather than Collection:
it documents expectations about ordering, uniqueness, and behavior of
equals. Do this across the board in Gerrit.

Mostly this is straightforward and I tried to exactly match existing
behavior where possible. However, there were a few wrinkles, where
different callers passed different subtypes to the same method.

The main one is arguments to ParameterParser#parse and
splitQueryString, where some callers used SetMultimaps (perhaps
semi-intentionally, or perhaps misunderstanding the nature of
HashMultimap). For the purposes of parameter parsing, a ListMultimap
makes more sense, because it preserves argument order and repetition.

Another instance is a couple places in ReceiveCommits and downstream
where there were SetMultimap<?, Ref>. Since Refs do not implement
equals, this is effectively the same thing as a ListMultimap, and
changing the interface no longer misleads readers into thinking there
might be some deduplication happening.

Finally, this change includes a breaking API change to the return
type of ExternalIncludedIn#getIncludedIn.

Change-Id: I5f1d15e27a32e534a6aaefe204e7a31815f4c8d7
This commit is contained in:
Dave Borowitz 2017-01-13 16:26:45 -05:00 committed by David Pursehouse
parent e5c5953205
commit 484da493b3
76 changed files with 367 additions and 355 deletions

View File

@ -19,7 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.UserScopedEventListener; import com.google.gerrit.common.UserScopedEventListener;
import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.registration.RegistrationHandle; import com.google.gerrit.extensions.registration.RegistrationHandle;
@ -39,7 +39,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
public class EventRecorder { public class EventRecorder {
private final RegistrationHandle eventListenerRegistration; private final RegistrationHandle eventListenerRegistration;
private final Multimap<String, RefEvent> recordedEvents; private final ListMultimap<String, RefEvent> recordedEvents;
@Singleton @Singleton
public static class Factory { public static class Factory {

View File

@ -14,7 +14,7 @@
package com.google.gerrit.extensions.config; package com.google.gerrit.extensions.config;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.annotations.ExtensionPoint; import com.google.gerrit.extensions.annotations.ExtensionPoint;
import java.util.Collection; import java.util.Collection;
@ -37,6 +37,6 @@ public interface ExternalIncludedIn {
* @param branches the branches that include the commit * @param branches the branches that include the commit
* @return additional entries for IncludedInInfo * @return additional entries for IncludedInInfo
*/ */
Multimap<String, String> getIncludedIn(String project, String commit, ListMultimap<String, String> getIncludedIn(String project, String commit,
Collection<String> tags, Collection<String> branches); Collection<String> tags, Collection<String> branches);
} }

View File

@ -14,7 +14,7 @@
package com.google.gerrit.extensions.restapi; package com.google.gerrit.extensions.restapi;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
/** /**
* Optional interface for {@link RestCollection}. * Optional interface for {@link RestCollection}.
@ -28,5 +28,5 @@ public interface NeedsParams {
* *
* @param params the request parameter * @param params the request parameter
*/ */
void setParams(Multimap<String, String> params) throws RestApiException; void setParams(ListMultimap<String, String> params) throws RestApiException;
} }

View File

@ -17,7 +17,7 @@ package com.google.gerrit.httpd.plugins;
import static com.google.gerrit.server.plugins.AutoRegisterUtil.calculateBindAnnotation; import static com.google.gerrit.server.plugins.AutoRegisterUtil.calculateBindAnnotation;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.annotations.Export; import com.google.gerrit.extensions.annotations.Export;
import com.google.gerrit.server.plugins.InvalidPluginException; import com.google.gerrit.server.plugins.InvalidPluginException;
import com.google.gerrit.server.plugins.ModuleGenerator; import com.google.gerrit.server.plugins.ModuleGenerator;
@ -35,7 +35,8 @@ import javax.servlet.http.HttpServlet;
class HttpAutoRegisterModuleGenerator extends ServletModule class HttpAutoRegisterModuleGenerator extends ServletModule
implements ModuleGenerator { implements ModuleGenerator {
private final Map<String, Class<HttpServlet>> serve = new HashMap<>(); private final Map<String, Class<HttpServlet>> serve = new HashMap<>();
private final Multimap<TypeLiteral<?>, Class<?>> listeners = LinkedListMultimap.create(); private final ListMultimap<TypeLiteral<?>, Class<?>> listeners =
LinkedListMultimap.create();
@Override @Override
protected void configureServlets() { protected void configureServlets() {

View File

@ -23,7 +23,7 @@ import com.google.common.base.Splitter;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.BinaryResult; import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.Url; import com.google.gerrit.extensions.restapi.Url;
@ -59,7 +59,7 @@ class ParameterParser {
} }
<T> boolean parse(T param, <T> boolean parse(T param,
Multimap<String, String> in, ListMultimap<String, String> in,
HttpServletRequest req, HttpServletRequest req,
HttpServletResponse res) HttpServletResponse res)
throws IOException { throws IOException {
@ -90,8 +90,8 @@ class ParameterParser {
} }
static void splitQueryString(String queryString, static void splitQueryString(String queryString,
Multimap<String, String> config, ListMultimap<String, String> config,
Multimap<String, String> params) { ListMultimap<String, String> params) {
if (!Strings.isNullOrEmpty(queryString)) { if (!Strings.isNullOrEmpty(queryString)) {
for (String kvPair : Splitter.on('&').split(queryString)) { for (String kvPair : Splitter.on('&').split(queryString)) {
Iterator<String> i = Splitter.on('=').limit(2).split(kvPair).iterator(); Iterator<String> i = Splitter.on('=').limit(2).split(kvPair).iterator();

View File

@ -45,13 +45,13 @@ import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import com.google.common.io.CountingOutputStream; import com.google.common.io.CountingOutputStream;
import com.google.common.math.IntMath; import com.google.common.math.IntMath;
@ -245,8 +245,8 @@ public class RestApiServlet extends HttpServlet {
int status = SC_OK; int status = SC_OK;
long responseBytes = -1; long responseBytes = -1;
Object result = null; Object result = null;
Multimap<String, String> params = LinkedHashMultimap.create(); ListMultimap<String, String> params = ArrayListMultimap.create();
Multimap<String, String> config = LinkedHashMultimap.create(); ListMultimap<String, String> config = ArrayListMultimap.create();
Object inputRequestBody = null; Object inputRequestBody = null;
RestResource rsrc = TopLevelResource.INSTANCE; RestResource rsrc = TopLevelResource.INSTANCE;
ViewData viewData = null; ViewData viewData = null;
@ -460,9 +460,9 @@ public class RestApiServlet extends HttpServlet {
metric, metric,
System.nanoTime() - startNanos, System.nanoTime() - startNanos,
TimeUnit.NANOSECONDS); TimeUnit.NANOSECONDS);
globals.auditService.dispatch(new ExtendedHttpAuditEvent(globals.webSession.get() globals.auditService.dispatch(new ExtendedHttpAuditEvent(
.getSessionId(), globals.currentUser.get(), req, globals.webSession.get().getSessionId(), globals.currentUser.get(),
auditStartTs, params, inputRequestBody, status, req, auditStartTs, params, inputRequestBody, status,
result, rsrc, viewData == null ? null : viewData.view)); result, rsrc, viewData == null ? null : viewData.view));
} }
} }
@ -777,7 +777,7 @@ public class RestApiServlet extends HttpServlet {
public static long replyJson(@Nullable HttpServletRequest req, public static long replyJson(@Nullable HttpServletRequest req,
HttpServletResponse res, HttpServletResponse res,
Multimap<String, String> config, ListMultimap<String, String> config,
Object result) Object result)
throws IOException { throws IOException {
TemporaryBuffer.Heap buf = heap(HEAP_EST_SIZE, Integer.MAX_VALUE); TemporaryBuffer.Heap buf = heap(HEAP_EST_SIZE, Integer.MAX_VALUE);
@ -796,7 +796,7 @@ public class RestApiServlet extends HttpServlet {
.setCharacterEncoding(UTF_8)); .setCharacterEncoding(UTF_8));
} }
private static Gson newGson(Multimap<String, String> config, private static Gson newGson(ListMultimap<String, String> config,
@Nullable HttpServletRequest req) { @Nullable HttpServletRequest req) {
GsonBuilder gb = OutputFormat.JSON_COMPACT.newGsonBuilder(); GsonBuilder gb = OutputFormat.JSON_COMPACT.newGsonBuilder();
@ -807,7 +807,7 @@ public class RestApiServlet extends HttpServlet {
} }
private static void enablePrettyPrint(GsonBuilder gb, private static void enablePrettyPrint(GsonBuilder gb,
Multimap<String, String> config, ListMultimap<String, String> config,
@Nullable HttpServletRequest req) { @Nullable HttpServletRequest req) {
String pp = Iterables.getFirst(config.get("pp"), null); String pp = Iterables.getFirst(config.get("pp"), null);
if (pp == null) { if (pp == null) {
@ -822,7 +822,7 @@ public class RestApiServlet extends HttpServlet {
} }
private static void enablePartialGetFields(GsonBuilder gb, private static void enablePartialGetFields(GsonBuilder gb,
Multimap<String, String> config) { ListMultimap<String, String> config) {
final Set<String> want = new HashSet<>(); final Set<String> want = new HashSet<>();
for (String p : config.get("fields")) { for (String p : config.get("fields")) {
Iterables.addAll(want, OptionUtil.splitOptionValue(p)); Iterables.addAll(want, OptionUtil.splitOptionValue(p));
@ -1130,7 +1130,8 @@ public class RestApiServlet extends HttpServlet {
static long replyText(@Nullable HttpServletRequest req, static long replyText(@Nullable HttpServletRequest req,
HttpServletResponse res, String text) throws IOException { HttpServletResponse res, String text) throws IOException {
if ((req == null || isRead(req)) && isMaybeHTML(text)) { if ((req == null || isRead(req)) && isMaybeHTML(text)) {
return replyJson(req, res, ImmutableMultimap.of("pp", "0"), new JsonPrimitive(text)); return replyJson(req, res, ImmutableListMultimap.of("pp", "0"),
new JsonPrimitive(text));
} }
if (!text.endsWith("\n")) { if (!text.endsWith("\n")) {
text += "\n"; text += "\n";

View File

@ -15,7 +15,7 @@
package com.google.gerrit.httpd.rpc; package com.google.gerrit.httpd.rpc;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.audit.AuditService; import com.google.gerrit.audit.AuditService;
import com.google.gerrit.audit.RpcAuditEvent; import com.google.gerrit.audit.RpcAuditEvent;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
@ -133,25 +133,28 @@ final class GerritJsonServlet extends JsonServlet<GerritJsonServlet.GerritCall>
} }
Audit note = method.getAnnotation(Audit.class); Audit note = method.getAnnotation(Audit.class);
if (note != null) { if (note != null) {
final String sid = call.getWebSession().getSessionId(); String sid = call.getWebSession().getSessionId();
final CurrentUser username = call.getWebSession().getUser(); CurrentUser username = call.getWebSession().getUser();
final Multimap<String, ?> args = ListMultimap<String, ?> args = extractParams(note, call);
extractParams(note, call); String what = extractWhat(note, call);
final String what = extractWhat(note, call); Object result = call.getResult();
final Object result = call.getResult();
audit.dispatch(new RpcAuditEvent(sid, username, what, call.getWhen(), audit.dispatch(
args, call.getHttpServletRequest().getMethod(), call.getHttpServletRequest().getMethod(), new RpcAuditEvent(
((AuditedHttpServletResponse) (call.getHttpServletResponse())) sid, username, what, call.getWhen(), args,
.getStatus(), result)); call.getHttpServletRequest().getMethod(),
call.getHttpServletRequest().getMethod(),
((AuditedHttpServletResponse) (call.getHttpServletResponse()))
.getStatus(),
result));
} }
} catch (Throwable all) { } catch (Throwable all) {
log.error("Unable to log the call", all); log.error("Unable to log the call", all);
} }
} }
private Multimap<String, ?> extractParams(final Audit note, final GerritCall call) { private ListMultimap<String, ?> extractParams(Audit note, GerritCall call) {
Multimap<String, Object> args = ArrayListMultimap.create(); ListMultimap<String, Object> args = ArrayListMultimap.create();
Object[] params = call.getParams(); Object[] params = call.getParams();
for (int i = 0; i < params.length; i++) { for (int i = 0; i < params.length; i++) {

View File

@ -15,8 +15,7 @@
package com.google.gerrit.httpd.rpc.doc; package com.google.gerrit.httpd.rpc.doc;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap;
import com.google.gerrit.httpd.restapi.RestApiServlet; import com.google.gerrit.httpd.restapi.RestApiServlet;
import com.google.gerrit.server.documentation.QueryDocumentationExecutor; import com.google.gerrit.server.documentation.QueryDocumentationExecutor;
import com.google.gerrit.server.documentation.QueryDocumentationExecutor.DocQueryException; import com.google.gerrit.server.documentation.QueryDocumentationExecutor.DocQueryException;
@ -68,8 +67,7 @@ public class QueryDocumentationFilter implements Filter {
HttpServletResponse rsp = (HttpServletResponse) response; HttpServletResponse rsp = (HttpServletResponse) response;
try { try {
List<DocResult> result = searcher.doQuery(request.getParameter("q")); List<DocResult> result = searcher.doQuery(request.getParameter("q"));
Multimap<String, String> config = LinkedHashMultimap.create(); RestApiServlet.replyJson(req, rsp, ImmutableListMultimap.of(), result);
RestApiServlet.replyJson(req, rsp, config, result);
} catch (DocQueryException e) { } catch (DocQueryException e) {
log.error("Doc search failed:", e); log.error("Doc search failed:", e);
rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

View File

@ -28,7 +28,7 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.ListeningExecutorService;
@ -408,9 +408,9 @@ public class LuceneChangeIndex implements ChangeIndex {
} }
} }
private static Multimap<String, IndexableField> fields(Document doc, private static ListMultimap<String, IndexableField> fields(Document doc,
Set<String> fields) { Set<String> fields) {
Multimap<String, IndexableField> stored = ListMultimap<String, IndexableField> stored =
ArrayListMultimap.create(fields.size(), 4); ArrayListMultimap.create(fields.size(), 4);
for (IndexableField f : doc) { for (IndexableField f : doc) {
String name = f.name(); String name = f.name();
@ -421,7 +421,7 @@ public class LuceneChangeIndex implements ChangeIndex {
return stored; return stored;
} }
private ChangeData toChangeData(Multimap<String, IndexableField> doc, private ChangeData toChangeData(ListMultimap<String, IndexableField> doc,
Set<String> fields, String idFieldName) { Set<String> fields, String idFieldName) {
ChangeData cd; ChangeData cd;
// Either change or the ID field was guaranteed to be included in the call // Either change or the ID field was guaranteed to be included in the call
@ -482,7 +482,8 @@ public class LuceneChangeIndex implements ChangeIndex {
return cd; return cd;
} }
private void decodePatchSets(Multimap<String, IndexableField> doc, ChangeData cd) { private void decodePatchSets(ListMultimap<String, IndexableField> doc,
ChangeData cd) {
List<PatchSet> patchSets = List<PatchSet> patchSets =
decodeProtos(doc, PATCH_SET_FIELD, PatchSetProtoField.CODEC); decodeProtos(doc, PATCH_SET_FIELD, PatchSetProtoField.CODEC);
if (!patchSets.isEmpty()) { if (!patchSets.isEmpty()) {
@ -492,12 +493,14 @@ public class LuceneChangeIndex implements ChangeIndex {
} }
} }
private void decodeApprovals(Multimap<String, IndexableField> doc, ChangeData cd) { private void decodeApprovals(ListMultimap<String, IndexableField> doc,
ChangeData cd) {
cd.setCurrentApprovals( cd.setCurrentApprovals(
decodeProtos(doc, APPROVAL_FIELD, PatchSetApprovalProtoField.CODEC)); decodeProtos(doc, APPROVAL_FIELD, PatchSetApprovalProtoField.CODEC));
} }
private void decodeChangedLines(Multimap<String, IndexableField> doc, ChangeData cd) { private void decodeChangedLines(ListMultimap<String, IndexableField> doc,
ChangeData cd) {
IndexableField added = Iterables.getFirst(doc.get(ADDED_FIELD), null); IndexableField added = Iterables.getFirst(doc.get(ADDED_FIELD), null);
IndexableField deleted = Iterables.getFirst(doc.get(DELETED_FIELD), null); IndexableField deleted = Iterables.getFirst(doc.get(DELETED_FIELD), null);
if (added != null && deleted != null) { if (added != null && deleted != null) {
@ -513,7 +516,8 @@ public class LuceneChangeIndex implements ChangeIndex {
} }
} }
private void decodeMergeable(Multimap<String, IndexableField> doc, ChangeData cd) { private void decodeMergeable(ListMultimap<String, IndexableField> doc,
ChangeData cd) {
IndexableField f = Iterables.getFirst(doc.get(MERGEABLE_FIELD), null); IndexableField f = Iterables.getFirst(doc.get(MERGEABLE_FIELD), null);
if (f != null) { if (f != null) {
String mergeable = f.stringValue(); String mergeable = f.stringValue();
@ -525,7 +529,8 @@ public class LuceneChangeIndex implements ChangeIndex {
} }
} }
private void decodeReviewedBy(Multimap<String, IndexableField> doc, ChangeData cd) { private void decodeReviewedBy(ListMultimap<String, IndexableField> doc,
ChangeData cd) {
Collection<IndexableField> reviewedBy = doc.get(REVIEWEDBY_FIELD); Collection<IndexableField> reviewedBy = doc.get(REVIEWEDBY_FIELD);
if (reviewedBy.size() > 0) { if (reviewedBy.size() > 0) {
Set<Account.Id> accounts = Set<Account.Id> accounts =
@ -541,7 +546,8 @@ public class LuceneChangeIndex implements ChangeIndex {
} }
} }
private void decodeHashtags(Multimap<String, IndexableField> doc, ChangeData cd) { private void decodeHashtags(ListMultimap<String, IndexableField> doc,
ChangeData cd) {
Collection<IndexableField> hashtag = doc.get(HASHTAG_FIELD); Collection<IndexableField> hashtag = doc.get(HASHTAG_FIELD);
Set<String> hashtags = Sets.newHashSetWithExpectedSize(hashtag.size()); Set<String> hashtags = Sets.newHashSetWithExpectedSize(hashtag.size());
for (IndexableField r : hashtag) { for (IndexableField r : hashtag) {
@ -550,9 +556,10 @@ public class LuceneChangeIndex implements ChangeIndex {
cd.setHashtags(hashtags); cd.setHashtags(hashtags);
} }
private void decodeStar(Multimap<String, IndexableField> doc, ChangeData cd) { private void decodeStar(ListMultimap<String, IndexableField> doc,
ChangeData cd) {
Collection<IndexableField> star = doc.get(STAR_FIELD); Collection<IndexableField> star = doc.get(STAR_FIELD);
Multimap<Account.Id, String> stars = ArrayListMultimap.create(); ListMultimap<Account.Id, String> stars = ArrayListMultimap.create();
for (IndexableField r : star) { for (IndexableField r : star) {
StarredChangesUtil.StarField starField = StarredChangesUtil.StarField starField =
StarredChangesUtil.StarField.parse(r.stringValue()); StarredChangesUtil.StarField.parse(r.stringValue());
@ -563,7 +570,7 @@ public class LuceneChangeIndex implements ChangeIndex {
cd.setStars(stars); cd.setStars(stars);
} }
private void decodeReviewers(Multimap<String, IndexableField> doc, private void decodeReviewers(ListMultimap<String, IndexableField> doc,
ChangeData cd) { ChangeData cd) {
cd.setReviewers( cd.setReviewers(
ChangeField.parseReviewerFieldValues( ChangeField.parseReviewerFieldValues(
@ -571,7 +578,7 @@ public class LuceneChangeIndex implements ChangeIndex {
.transform(IndexableField::stringValue))); .transform(IndexableField::stringValue)));
} }
private void decodeSubmitRecords(Multimap<String, IndexableField> doc, private void decodeSubmitRecords(ListMultimap<String, IndexableField> doc,
String field, SubmitRuleOptions opts, ChangeData cd) { String field, SubmitRuleOptions opts, ChangeData cd) {
ChangeField.parseSubmitRecords( ChangeField.parseSubmitRecords(
Collections2.transform( Collections2.transform(
@ -579,17 +586,18 @@ public class LuceneChangeIndex implements ChangeIndex {
opts, cd); opts, cd);
} }
private void decodeRefStates(Multimap<String, IndexableField> doc, private void decodeRefStates(ListMultimap<String, IndexableField> doc,
ChangeData cd) { ChangeData cd) {
cd.setRefStates(copyAsBytes(doc.get(REF_STATE_FIELD))); cd.setRefStates(copyAsBytes(doc.get(REF_STATE_FIELD)));
} }
private void decodeRefStatePatterns(Multimap<String, IndexableField> doc, private void decodeRefStatePatterns(ListMultimap<String, IndexableField> doc,
ChangeData cd) { ChangeData cd) {
cd.setRefStatePatterns(copyAsBytes(doc.get(REF_STATE_PATTERN_FIELD))); cd.setRefStatePatterns(copyAsBytes(doc.get(REF_STATE_PATTERN_FIELD)));
} }
private static <T> List<T> decodeProtos(Multimap<String, IndexableField> doc, private static <T> List<T> decodeProtos(
ListMultimap<String, IndexableField> doc,
String fieldName, ProtobufCodec<T> codec) { String fieldName, ProtobufCodec<T> codec) {
Collection<IndexableField> fields = doc.get(fieldName); Collection<IndexableField> fields = doc.get(fieldName);
if (fields.isEmpty()) { if (fields.isEmpty()) {

View File

@ -21,9 +21,9 @@ import static com.google.gerrit.server.schema.DataSourceProvider.Context.MULTI_U
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.base.Stopwatch; import com.google.common.base.Stopwatch;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -153,7 +153,7 @@ public class RebuildNoteDb extends SiteProgram {
ListeningExecutorService executor = newExecutor(); ListeningExecutorService executor = newExecutor();
System.out.println("Rebuilding the NoteDb"); System.out.println("Rebuilding the NoteDb");
final ImmutableMultimap<Project.NameKey, Change.Id> changesByProject = ImmutableListMultimap<Project.NameKey, Change.Id> changesByProject =
getChangesByProject(); getChangesByProject();
boolean ok; boolean ok;
Stopwatch sw = Stopwatch.createStarted(); Stopwatch sw = Stopwatch.createStarted();
@ -241,11 +241,11 @@ public class RebuildNoteDb extends SiteProgram {
return MoreExecutors.newDirectExecutorService(); return MoreExecutors.newDirectExecutorService();
} }
private ImmutableMultimap<Project.NameKey, Change.Id> getChangesByProject() private ImmutableListMultimap<Project.NameKey, Change.Id> getChangesByProject()
throws OrmException { throws OrmException {
// Memorize all changes so we can close the db connection and allow // Memorize all changes so we can close the db connection and allow
// rebuilder threads to use the full connection pool. // rebuilder threads to use the full connection pool.
Multimap<Project.NameKey, Change.Id> changesByProject = ListMultimap<Project.NameKey, Change.Id> changesByProject =
ArrayListMultimap.create(); ArrayListMultimap.create();
try (ReviewDb db = schemaFactory.open()) { try (ReviewDb db = schemaFactory.open()) {
if (projects.isEmpty() && !changes.isEmpty()) { if (projects.isEmpty() && !changes.isEmpty()) {
@ -270,12 +270,12 @@ public class RebuildNoteDb extends SiteProgram {
} }
} }
} }
return ImmutableMultimap.copyOf(changesByProject); return ImmutableListMultimap.copyOf(changesByProject);
} }
} }
private boolean rebuildProject(ReviewDb db, private boolean rebuildProject(ReviewDb db,
ImmutableMultimap<Project.NameKey, Change.Id> allChanges, ImmutableListMultimap<Project.NameKey, Change.Id> allChanges,
Project.NameKey project, Repository allUsersRepo) Project.NameKey project, Repository allUsersRepo)
throws IOException, OrmException { throws IOException, OrmException {
checkArgument(allChanges.containsKey(project)); checkArgument(allChanges.containsKey(project));

View File

@ -17,22 +17,22 @@ package com.google.gerrit.audit;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Multimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
public class AuditEvent { public class AuditEvent {
public static final String UNKNOWN_SESSION_ID = "000000000000000000000000000"; public static final String UNKNOWN_SESSION_ID = "000000000000000000000000000";
protected static final Multimap<String, ?> EMPTY_PARAMS = protected static final ListMultimap<String, ?> EMPTY_PARAMS =
MultimapBuilder.hashKeys().hashSetValues().build(); ImmutableListMultimap.of();
public final String sessionId; public final String sessionId;
public final CurrentUser who; public final CurrentUser who;
public final long when; public final long when;
public final String what; public final String what;
public final Multimap<String, ?> params; public final ListMultimap<String, ?> params;
public final Object result; public final Object result;
public final long timeAtStart; public final long timeAtStart;
public final long elapsed; public final long elapsed;
@ -59,7 +59,7 @@ public class AuditEvent {
* @param result result of the event * @param result result of the event
*/ */
public AuditEvent(String sessionId, CurrentUser who, String what, long when, public AuditEvent(String sessionId, CurrentUser who, String what, long when,
Multimap<String, ?> params, Object result) { ListMultimap<String, ?> params, Object result) {
Preconditions.checkNotNull(what, "what is a mandatory not null param !"); Preconditions.checkNotNull(what, "what is a mandatory not null param !");
this.sessionId = MoreObjects.firstNonNull(sessionId, UNKNOWN_SESSION_ID); this.sessionId = MoreObjects.firstNonNull(sessionId, UNKNOWN_SESSION_ID);

View File

@ -15,7 +15,7 @@
package com.google.gerrit.audit; package com.google.gerrit.audit;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.restapi.RestResource; import com.google.gerrit.extensions.restapi.RestResource;
import com.google.gerrit.extensions.restapi.RestView; import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
@ -45,11 +45,11 @@ public class ExtendedHttpAuditEvent extends HttpAuditEvent {
* @param view view rendering object * @param view view rendering object
*/ */
public ExtendedHttpAuditEvent(String sessionId, CurrentUser who, public ExtendedHttpAuditEvent(String sessionId, CurrentUser who,
HttpServletRequest httpRequest, long when, Multimap<String, ?> params, HttpServletRequest httpRequest, long when, ListMultimap<String, ?> params,
Object input, int status, Object result, RestResource resource, Object input, int status, Object result, RestResource resource,
RestView<RestResource> view) { RestView<RestResource> view) {
super(sessionId, who, httpRequest.getRequestURI(), when, params, httpRequest.getMethod(), super(sessionId, who, httpRequest.getRequestURI(), when, params,
input, status, result); httpRequest.getMethod(), input, status, result);
this.httpRequest = Preconditions.checkNotNull(httpRequest); this.httpRequest = Preconditions.checkNotNull(httpRequest);
this.resource = resource; this.resource = resource;
this.view = view; this.view = view;

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
package com.google.gerrit.audit; package com.google.gerrit.audit;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
public class HttpAuditEvent extends AuditEvent { public class HttpAuditEvent extends AuditEvent {
@ -34,8 +34,9 @@ public class HttpAuditEvent extends AuditEvent {
* @param status HTTP status * @param status HTTP status
* @param result result of the event * @param result result of the event
*/ */
public HttpAuditEvent(String sessionId, CurrentUser who, String what, long when, public HttpAuditEvent(String sessionId, CurrentUser who, String what,
Multimap<String, ?> params, String httpMethod, Object input, int status, Object result) { long when, ListMultimap<String, ?> params, String httpMethod,
Object input, int status, Object result) {
super(sessionId, who, what, when, params, result); super(sessionId, who, what, when, params, result);
this.httpMethod = httpMethod; this.httpMethod = httpMethod;
this.input = input; this.input = input;

View File

@ -11,9 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package com.google.gerrit.audit; package com.google.gerrit.audit;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
public class RpcAuditEvent extends HttpAuditEvent { public class RpcAuditEvent extends HttpAuditEvent {
@ -32,8 +33,8 @@ public class RpcAuditEvent extends HttpAuditEvent {
* @param result result of the event * @param result result of the event
*/ */
public RpcAuditEvent(String sessionId, CurrentUser who, String what, public RpcAuditEvent(String sessionId, CurrentUser who, String what,
long when, Multimap<String, ?> params, String httpMethod, Object input, long when, ListMultimap<String, ?> params, String httpMethod,
int status, Object result) { Object input, int status, Object result) {
super(sessionId, who, what, when, params, httpMethod, input, status, result); super(sessionId, who, what, when, params, httpMethod, input, status, result);
} }
} }

View File

@ -11,15 +11,16 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package com.google.gerrit.audit; package com.google.gerrit.audit;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
public class SshAuditEvent extends AuditEvent { public class SshAuditEvent extends AuditEvent {
public SshAuditEvent(String sessionId, CurrentUser who, String what, public SshAuditEvent(String sessionId, CurrentUser who, String what,
long when, Multimap<String, ?> params, Object result) { long when, ListMultimap<String, ?> params, Object result) {
super(sessionId, who, what, when, params, result); super(sessionId, who, what, when, params, result);
} }
} }

View File

@ -11,10 +11,11 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package com.google.gerrit.rules; package com.google.gerrit.rules;
import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.SetMultimap;
import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.registration.DynamicSet;
import java.util.Collection; import java.util.Collection;
@ -24,7 +25,7 @@ import java.util.Collection;
*/ */
public class PredicateClassLoader extends ClassLoader { public class PredicateClassLoader extends ClassLoader {
private final Multimap<String, ClassLoader> packageClassLoaderMap = private final SetMultimap<String, ClassLoader> packageClassLoaderMap =
LinkedHashMultimap.create(); LinkedHashMultimap.create();
public PredicateClassLoader( public PredicateClassLoader(

View File

@ -23,8 +23,8 @@ import com.google.auto.value.AutoValue;
import com.google.common.base.CharMatcher; import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
@ -314,7 +314,7 @@ public class StarredChangesUtil {
} }
} }
public ImmutableMultimap<Account.Id, String> byChangeFromIndex( public ImmutableListMultimap<Account.Id, String> byChangeFromIndex(
Change.Id changeId) throws OrmException { Change.Id changeId) throws OrmException {
Set<String> fields = ImmutableSet.of( Set<String> fields = ImmutableSet.of(
ChangeField.ID.getName(), ChangeField.ID.getName(),

View File

@ -17,7 +17,7 @@ package com.google.gerrit.server.account;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountExternalId; import com.google.gerrit.reviewdb.client.AccountExternalId;
@ -76,7 +76,7 @@ public class ExternalIdCacheImpl implements ExternalIdCache {
public void onCreate(Iterable<AccountExternalId> extIds) { public void onCreate(Iterable<AccountExternalId> extIds) {
lock.lock(); lock.lock();
try { try {
Multimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys() ListMultimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
.arrayListValues().build(extIdsByAccount.get(AllKey.ALL)); .arrayListValues().build(extIdsByAccount.get(AllKey.ALL));
for (AccountExternalId extId : extIds) { for (AccountExternalId extId : extIds) {
n.put(extId.getAccountId(), extId); n.put(extId.getAccountId(), extId);
@ -93,7 +93,7 @@ public class ExternalIdCacheImpl implements ExternalIdCache {
public void onRemove(Iterable<AccountExternalId> extIds) { public void onRemove(Iterable<AccountExternalId> extIds) {
lock.lock(); lock.lock();
try { try {
Multimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys() ListMultimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
.arrayListValues().build(extIdsByAccount.get(AllKey.ALL)); .arrayListValues().build(extIdsByAccount.get(AllKey.ALL));
for (AccountExternalId extId : extIds) { for (AccountExternalId extId : extIds) {
n.remove(extId.getAccountId(), extId); n.remove(extId.getAccountId(), extId);
@ -111,7 +111,7 @@ public class ExternalIdCacheImpl implements ExternalIdCache {
Iterable<AccountExternalId.Key> extIdKeys) { Iterable<AccountExternalId.Key> extIdKeys) {
lock.lock(); lock.lock();
try { try {
Multimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys() ListMultimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
.arrayListValues().build(extIdsByAccount.get(AllKey.ALL)); .arrayListValues().build(extIdsByAccount.get(AllKey.ALL));
for (AccountExternalId extId : byAccount(accountId)) { for (AccountExternalId extId : byAccount(accountId)) {
for (AccountExternalId.Key extIdKey : extIdKeys) { for (AccountExternalId.Key extIdKey : extIdKeys) {
@ -133,7 +133,7 @@ public class ExternalIdCacheImpl implements ExternalIdCache {
public void onUpdate(AccountExternalId updatedExtId) { public void onUpdate(AccountExternalId updatedExtId) {
lock.lock(); lock.lock();
try { try {
Multimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys() ListMultimap<Account.Id, AccountExternalId> n = MultimapBuilder.hashKeys()
.arrayListValues().build(extIdsByAccount.get(AllKey.ALL)); .arrayListValues().build(extIdsByAccount.get(AllKey.ALL));
for (AccountExternalId extId : byAccount(updatedExtId.getAccountId())) { for (AccountExternalId extId : byAccount(updatedExtId.getAccountId())) {
if (updatedExtId.getKey().equals(extId.getKey())) { if (updatedExtId.getKey().equals(extId.getKey())) {
@ -181,7 +181,7 @@ public class ExternalIdCacheImpl implements ExternalIdCache {
public ImmutableSetMultimap<Account.Id, AccountExternalId> load(AllKey key) public ImmutableSetMultimap<Account.Id, AccountExternalId> load(AllKey key)
throws Exception { throws Exception {
try (ReviewDb db = schema.open()) { try (ReviewDb db = schema.open()) {
Multimap<Account.Id, AccountExternalId> extIdsByAccount = ListMultimap<Account.Id, AccountExternalId> extIdsByAccount =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (AccountExternalId extId : db.accountExternalIds().all()) { for (AccountExternalId extId : db.accountExternalIds().all()) {
extIdsByAccount.put(extId.getAccountId(), extId); extIdsByAccount.put(extId.getAccountId(), extId);

View File

@ -18,7 +18,7 @@ import static com.google.gerrit.server.account.GroupBackends.GROUP_REF_NAME_COMP
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
@ -138,7 +138,7 @@ public class UniversalGroupBackend implements GroupBackend {
@Override @Override
public boolean containsAnyOf(Iterable<AccountGroup.UUID> uuids) { public boolean containsAnyOf(Iterable<AccountGroup.UUID> uuids) {
Multimap<GroupMembership, AccountGroup.UUID> lookups = ListMultimap<GroupMembership, AccountGroup.UUID> lookups =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (AccountGroup.UUID uuid : uuids) { for (AccountGroup.UUID uuid : uuids) {
if (uuid == null) { if (uuid == null) {
@ -168,7 +168,7 @@ public class UniversalGroupBackend implements GroupBackend {
@Override @Override
public Set<AccountGroup.UUID> intersection(Iterable<AccountGroup.UUID> uuids) { public Set<AccountGroup.UUID> intersection(Iterable<AccountGroup.UUID> uuids) {
Multimap<GroupMembership, AccountGroup.UUID> lookups = ListMultimap<GroupMembership, AccountGroup.UUID> lookups =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (AccountGroup.UUID uuid : uuids) { for (AccountGroup.UUID uuid : uuids) {
if (uuid == null) { if (uuid == null) {

View File

@ -25,7 +25,7 @@ import com.google.common.base.Splitter;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
@ -269,7 +269,7 @@ public class WatchConfig extends VersionedMetaData
cfg.unsetSection(PROJECT, projectName); cfg.unsetSection(PROJECT, projectName);
} }
Multimap<String, String> notifyValuesByProject = ListMultimap<String, String> notifyValuesByProject =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (Map.Entry<ProjectWatchKey, Set<NotifyType>> e : projectWatches for (Map.Entry<ProjectWatchKey, Set<NotifyType>> e : projectWatches
.entrySet()) { .entrySet()) {

View File

@ -15,7 +15,7 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.api.changes.AbandonInput; import com.google.gerrit.extensions.api.changes.AbandonInput;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
@ -95,7 +95,7 @@ public class Abandon implements RestModifyView<ChangeResource, AbandonInput>,
public Change abandon(ChangeControl control, String msgTxt, public Change abandon(ChangeControl control, String msgTxt,
NotifyHandling notifyHandling, NotifyHandling notifyHandling,
Multimap<RecipientType, Account.Id> accountsToNotify) ListMultimap<RecipientType, Account.Id> accountsToNotify)
throws RestApiException, UpdateException { throws RestApiException, UpdateException {
CurrentUser user = control.getUser(); CurrentUser user = control.getUser();
Account account = user.isIdentifiedUser() Account account = user.isIdentifiedUser()
@ -125,7 +125,7 @@ public class Abandon implements RestModifyView<ChangeResource, AbandonInput>,
public void batchAbandon(Project.NameKey project, CurrentUser user, public void batchAbandon(Project.NameKey project, CurrentUser user,
Collection<ChangeControl> controls, String msgTxt, Collection<ChangeControl> controls, String msgTxt,
NotifyHandling notifyHandling, NotifyHandling notifyHandling,
Multimap<RecipientType, Account.Id> accountsToNotify) ListMultimap<RecipientType, Account.Id> accountsToNotify)
throws RestApiException, UpdateException { throws RestApiException, UpdateException {
if (controls.isEmpty()) { if (controls.isEmpty()) {
return; return;

View File

@ -14,8 +14,8 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.InternalUser; import com.google.gerrit.server.InternalUser;
import com.google.gerrit.server.config.ChangeCleanupConfig; import com.google.gerrit.server.config.ChangeCleanupConfig;
@ -78,15 +78,15 @@ public class AbandonUtil {
.enforceVisibility(false) .enforceVisibility(false)
.query(queryBuilder.parse(query)) .query(queryBuilder.parse(query))
.entities(); .entities();
ImmutableMultimap.Builder<Project.NameKey, ChangeControl> builder = ImmutableListMultimap.Builder<Project.NameKey, ChangeControl> builder =
ImmutableMultimap.builder(); ImmutableListMultimap.builder();
for (ChangeData cd : changesToAbandon) { for (ChangeData cd : changesToAbandon) {
ChangeControl control = cd.changeControl(internalUser); ChangeControl control = cd.changeControl(internalUser);
builder.put(control.getProject().getNameKey(), control); builder.put(control.getProject().getNameKey(), control);
} }
int count = 0; int count = 0;
Multimap<Project.NameKey, ChangeControl> abandons = builder.build(); ListMultimap<Project.NameKey, ChangeControl> abandons = builder.build();
String message = cfg.getAbandonMessage(); String message = cfg.getAbandonMessage();
for (Project.NameKey project : abandons.keySet()) { for (Project.NameKey project : abandons.keySet()) {
Collection<ChangeControl> changes = Collection<ChangeControl> changes =

View File

@ -21,7 +21,7 @@ import static java.util.stream.Collectors.toSet;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.FooterConstants; import com.google.gerrit.common.FooterConstants;
import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes; import com.google.gerrit.common.data.LabelTypes;
@ -114,7 +114,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
private CommitValidators.Policy validatePolicy = private CommitValidators.Policy validatePolicy =
CommitValidators.Policy.GERRIT; CommitValidators.Policy.GERRIT;
private NotifyHandling notify = NotifyHandling.ALL; private NotifyHandling notify = NotifyHandling.ALL;
private Multimap<RecipientType, Account.Id> accountsToNotify = private ListMultimap<RecipientType, Account.Id> accountsToNotify =
ImmutableListMultimap.of(); ImmutableListMultimap.of();
private Set<Account.Id> reviewers; private Set<Account.Id> reviewers;
private Set<Account.Id> extraCC; private Set<Account.Id> extraCC;
@ -240,7 +240,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
} }
public ChangeInserter setAccountsToNotify( public ChangeInserter setAccountsToNotify(
Multimap<RecipientType, Account.Id> accountsToNotify) { ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.accountsToNotify = checkNotNull(accountsToNotify); this.accountsToNotify = checkNotNull(accountsToNotify);
return this; return this;
} }

View File

@ -50,7 +50,6 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap; import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -821,7 +820,7 @@ public class ChangeJson {
} }
Set<String> labelNames = new HashSet<>(); Set<String> labelNames = new HashSet<>();
Multimap<Account.Id, PatchSetApproval> current = SetMultimap<Account.Id, PatchSetApproval> current =
MultimapBuilder.hashKeys().hashSetValues().build(); MultimapBuilder.hashKeys().hashSetValues().build();
for (PatchSetApproval a : cd.currentApprovals()) { for (PatchSetApproval a : cd.currentApprovals()) {
allUsers.add(a.getAccountId()); allUsers.add(a.getAccountId());

View File

@ -23,8 +23,8 @@ import static com.google.gerrit.server.ChangeUtil.PS_ID_ORDER;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap;
import com.google.gerrit.common.FooterConstants; import com.google.gerrit.common.FooterConstants;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
@ -126,7 +126,7 @@ public class ConsistencyChecker {
private RevWalk rw; private RevWalk rw;
private RevCommit tip; private RevCommit tip;
private Multimap<ObjectId, PatchSet> patchSetsBySha; private SetMultimap<ObjectId, PatchSet> patchSetsBySha;
private PatchSet currPs; private PatchSet currPs;
private RevCommit currPsCommit; private RevCommit currPsCommit;

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.change;
import static com.google.gerrit.server.CommentsUtil.COMMENT_ORDER; import static com.google.gerrit.server.CommentsUtil.COMMENT_ORDER;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.extensions.api.changes.RecipientType;
@ -53,7 +53,7 @@ public class EmailReviewComments implements Runnable, RequestContext {
interface Factory { interface Factory {
EmailReviewComments create( EmailReviewComments create(
NotifyHandling notify, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify, ListMultimap<RecipientType, Account.Id> accountsToNotify,
ChangeNotes notes, ChangeNotes notes,
PatchSet patchSet, PatchSet patchSet,
IdentifiedUser user, IdentifiedUser user,
@ -70,7 +70,7 @@ public class EmailReviewComments implements Runnable, RequestContext {
private final ThreadLocalRequestContext requestContext; private final ThreadLocalRequestContext requestContext;
private final NotifyHandling notify; private final NotifyHandling notify;
private final Multimap<RecipientType, Account.Id> accountsToNotify; private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
private final ChangeNotes notes; private final ChangeNotes notes;
private final PatchSet patchSet; private final PatchSet patchSet;
private final IdentifiedUser user; private final IdentifiedUser user;
@ -88,7 +88,7 @@ public class EmailReviewComments implements Runnable, RequestContext {
SchemaFactory<ReviewDb> schemaFactory, SchemaFactory<ReviewDb> schemaFactory,
ThreadLocalRequestContext requestContext, ThreadLocalRequestContext requestContext,
@Assisted NotifyHandling notify, @Assisted NotifyHandling notify,
@Assisted Multimap<RecipientType, Account.Id> accountsToNotify, @Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify,
@Assisted ChangeNotes notes, @Assisted ChangeNotes notes,
@Assisted PatchSet patchSet, @Assisted PatchSet patchSet,
@Assisted IdentifiedUser user, @Assisted IdentifiedUser user,

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.extensions.config.ExternalIncludedIn; import com.google.gerrit.extensions.config.ExternalIncludedIn;
import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.registration.DynamicSet;
@ -81,10 +81,10 @@ class IncludedIn implements RestReadView<ChangeResource> {
} }
IncludedInResolver.Result d = IncludedInResolver.resolve(r, rw, rev); IncludedInResolver.Result d = IncludedInResolver.resolve(r, rw, rev);
Multimap<String, String> external = ListMultimap<String, String> external =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (ExternalIncludedIn ext : includedIn) { for (ExternalIncludedIn ext : includedIn) {
Multimap<String, String> extIncludedIns = ext.getIncludedIn( ListMultimap<String, String> extIncludedIns = ext.getIncludedIn(
project.get(), rev.name(), d.getTags(), d.getBranches()); project.get(), rev.name(), d.getTags(), d.getBranches());
if (extIncludedIns != null) { if (extIncludedIns != null) {
external.putAll(extIncludedIns); external.putAll(extIncludedIns);

View File

@ -15,8 +15,8 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.MissingObjectException;
@ -76,7 +76,7 @@ public class IncludedInResolver {
private final RevCommit target; private final RevCommit target;
private final RevFlag containsTarget; private final RevFlag containsTarget;
private Multimap<RevCommit, String> commitToRef; private ListMultimap<RevCommit, String> commitToRef;
private List<RevCommit> tipsByCommitTime; private List<RevCommit> tipsByCommitTime;
private IncludedInResolver(Repository repo, RevWalk rw, RevCommit target, private IncludedInResolver(Repository repo, RevWalk rw, RevCommit target,

View File

@ -18,7 +18,7 @@ import static java.util.stream.Collectors.joining;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.NotifyInfo; import com.google.gerrit.extensions.api.changes.NotifyInfo;
@ -77,14 +77,14 @@ public class NotifyUtil {
return notifyInfo.accounts == null || notifyInfo.accounts.isEmpty(); return notifyInfo.accounts == null || notifyInfo.accounts.isEmpty();
} }
public Multimap<RecipientType, Account.Id> resolveAccounts( public ListMultimap<RecipientType, Account.Id> resolveAccounts(
@Nullable Map<RecipientType, NotifyInfo> notifyDetails) @Nullable Map<RecipientType, NotifyInfo> notifyDetails)
throws OrmException, BadRequestException { throws OrmException, BadRequestException {
if (isNullOrEmpty(notifyDetails)) { if (isNullOrEmpty(notifyDetails)) {
return ImmutableListMultimap.of(); return ImmutableListMultimap.of();
} }
Multimap<RecipientType, Account.Id> m = null; ListMultimap<RecipientType, Account.Id> m = null;
for (Entry<RecipientType, NotifyInfo> e : notifyDetails.entrySet()) { for (Entry<RecipientType, NotifyInfo> e : notifyDetails.entrySet()) {
List<String> accounts = e.getValue().accounts; List<String> accounts = e.getValue().accounts;
if (accounts != null) { if (accounts != null) {

View File

@ -20,7 +20,7 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.CC;
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER; import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.extensions.api.changes.RecipientType;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
@ -100,7 +100,7 @@ public class PatchSetInserter extends BatchUpdate.Op {
private List<String> groups = Collections.emptyList(); private List<String> groups = Collections.emptyList();
private boolean fireRevisionCreated = true; private boolean fireRevisionCreated = true;
private NotifyHandling notify = NotifyHandling.ALL; private NotifyHandling notify = NotifyHandling.ALL;
private Multimap<RecipientType, Account.Id> accountsToNotify = private ListMultimap<RecipientType, Account.Id> accountsToNotify =
ImmutableListMultimap.of(); ImmutableListMultimap.of();
private boolean allowClosed; private boolean allowClosed;
private boolean copyApprovals = true; private boolean copyApprovals = true;
@ -185,7 +185,7 @@ public class PatchSetInserter extends BatchUpdate.Op {
} }
public PatchSetInserter setAccountsToNotify( public PatchSetInserter setAccountsToNotify(
Multimap<RecipientType, Account.Id> accountsToNotify) { ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.accountsToNotify = checkNotNull(accountsToNotify); this.accountsToNotify = checkNotNull(accountsToNotify);
return this; return this;
} }

View File

@ -27,9 +27,9 @@ import com.google.auto.value.AutoValue;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.common.hash.HashCode; import com.google.common.hash.HashCode;
import com.google.common.hash.Hashing; import com.google.common.hash.Hashing;
@ -207,7 +207,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
input.notify = NotifyHandling.NONE; input.notify = NotifyHandling.NONE;
} }
Multimap<RecipientType, Account.Id> accountsToNotify = ListMultimap<RecipientType, Account.Id> accountsToNotify =
notifyUtil.resolveAccounts(input.notifyDetails); notifyUtil.resolveAccounts(input.notifyDetails);
Map<String, AddReviewerResult> reviewerJsonResults = null; Map<String, AddReviewerResult> reviewerJsonResults = null;
@ -304,7 +304,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
private void emailReviewers(Change change, private void emailReviewers(Change change,
List<PostReviewers.Addition> reviewerAdditions, NotifyHandling notify, List<PostReviewers.Addition> reviewerAdditions, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify) { ListMultimap<RecipientType, Account.Id> accountsToNotify) {
List<Account.Id> to = new ArrayList<>(); List<Account.Id> to = new ArrayList<>();
List<Account.Id> cc = new ArrayList<>(); List<Account.Id> cc = new ArrayList<>();
for (PostReviewers.Addition addition : reviewerAdditions) { for (PostReviewers.Addition addition : reviewerAdditions) {
@ -671,7 +671,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
private class Op extends BatchUpdate.Op { private class Op extends BatchUpdate.Op {
private final PatchSet.Id psId; private final PatchSet.Id psId;
private final ReviewInput in; private final ReviewInput in;
private final Multimap<RecipientType, Account.Id> accountsToNotify; private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
private final List<PostReviewers.Addition> reviewerResults; private final List<PostReviewers.Addition> reviewerResults;
private IdentifiedUser user; private IdentifiedUser user;
@ -684,7 +684,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
private Map<String, Short> oldApprovals = new HashMap<>(); private Map<String, Short> oldApprovals = new HashMap<>();
private Op(PatchSet.Id psId, ReviewInput in, private Op(PatchSet.Id psId, ReviewInput in,
Multimap<RecipientType, Account.Id> accountsToNotify, ListMultimap<RecipientType, Account.Id> accountsToNotify,
List<PostReviewers.Addition> reviewerResults) { List<PostReviewers.Addition> reviewerResults) {
this.psId = psId; this.psId = psId;
this.in = in; this.in = in;

View File

@ -21,8 +21,8 @@ import static com.google.gerrit.extensions.client.ReviewerState.REVIEWER;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.errors.NoSuchGroupException; import com.google.gerrit.common.errors.NoSuchGroupException;
@ -201,7 +201,7 @@ public class PostReviewers
private Addition putAccount(String reviewer, ReviewerResource rsrc, private Addition putAccount(String reviewer, ReviewerResource rsrc,
ReviewerState state, NotifyHandling notify, ReviewerState state, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify) ListMultimap<RecipientType, Account.Id> accountsToNotify)
throws UnprocessableEntityException { throws UnprocessableEntityException {
Account member = rsrc.getReviewerUser().getAccount(); Account member = rsrc.getReviewerUser().getAccount();
ChangeControl control = rsrc.getReviewerControl(); ChangeControl control = rsrc.getReviewerControl();
@ -303,7 +303,7 @@ public class PostReviewers
protected Addition(String reviewer, ChangeResource rsrc, protected Addition(String reviewer, ChangeResource rsrc,
Map<Account.Id, ChangeControl> reviewers, ReviewerState state, Map<Account.Id, ChangeControl> reviewers, ReviewerState state,
NotifyHandling notify, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify) { ListMultimap<RecipientType, Account.Id> accountsToNotify) {
result = new AddReviewerResult(reviewer); result = new AddReviewerResult(reviewer);
if (reviewers == null) { if (reviewers == null) {
this.reviewers = ImmutableMap.of(); this.reviewers = ImmutableMap.of();
@ -342,7 +342,7 @@ public class PostReviewers
final Map<Account.Id, ChangeControl> reviewers; final Map<Account.Id, ChangeControl> reviewers;
final ReviewerState state; final ReviewerState state;
final NotifyHandling notify; final NotifyHandling notify;
final Multimap<RecipientType, Account.Id> accountsToNotify; final ListMultimap<RecipientType, Account.Id> accountsToNotify;
List<PatchSetApproval> addedReviewers; List<PatchSetApproval> addedReviewers;
Collection<Account.Id> addedCCs; Collection<Account.Id> addedCCs;
@ -351,7 +351,7 @@ public class PostReviewers
Op(ChangeResource rsrc, Map<Account.Id, ChangeControl> reviewers, Op(ChangeResource rsrc, Map<Account.Id, ChangeControl> reviewers,
ReviewerState state, NotifyHandling notify, ReviewerState state, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify) { ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.rsrc = rsrc; this.rsrc = rsrc;
this.reviewers = reviewers; this.reviewers = reviewers;
this.state = state; this.state = state;
@ -407,7 +407,7 @@ public class PostReviewers
public void emailReviewers(Change change, Collection<Account.Id> added, public void emailReviewers(Change change, Collection<Account.Id> added,
Collection<Account.Id> copied, NotifyHandling notify, Collection<Account.Id> copied, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify) { ListMultimap<RecipientType, Account.Id> accountsToNotify) {
if (added.isEmpty() && copied.isEmpty()) { if (added.isEmpty() && copied.isEmpty()) {
return; return;
} }

View File

@ -21,7 +21,7 @@ import com.google.common.base.MoreObjects;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.data.ParameterizedString; import com.google.gerrit.common.data.ParameterizedString;
import com.google.gerrit.extensions.api.changes.SubmitInput; import com.google.gerrit.extensions.api.changes.SubmitInput;
@ -418,7 +418,7 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
mergeabilityMap.add(change); mergeabilityMap.add(change);
} }
Multimap<Branch.NameKey, ChangeData> cbb = cs.changesByBranch(); ListMultimap<Branch.NameKey, ChangeData> cbb = cs.changesByBranch();
for (Branch.NameKey branch : cbb.keySet()) { for (Branch.NameKey branch : cbb.keySet()) {
Collection<ChangeData> targetBranch = cbb.get(branch); Collection<ChangeData> targetBranch = cbb.get(branch);
HashMap<Change.Id, RevCommit> commits = HashMap<Change.Id, RevCommit> commits =

View File

@ -20,7 +20,7 @@ import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
@ -105,7 +105,7 @@ class WalkSorter {
public Iterable<PatchSetData> sort(Iterable<ChangeData> in) public Iterable<PatchSetData> sort(Iterable<ChangeData> in)
throws OrmException, IOException { throws OrmException, IOException {
Multimap<Project.NameKey, ChangeData> byProject = ListMultimap<Project.NameKey, ChangeData> byProject =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (ChangeData cd : in) { for (ChangeData cd : in) {
byProject.put(cd.change().getProject(), cd); byProject.put(cd.change().getProject(), cd);
@ -126,7 +126,7 @@ class WalkSorter {
try (Repository repo = repoManager.openRepository(project); try (Repository repo = repoManager.openRepository(project);
RevWalk rw = new RevWalk(repo)) { RevWalk rw = new RevWalk(repo)) {
rw.setRetainBody(retainBody); rw.setRetainBody(retainBody);
Multimap<RevCommit, PatchSetData> byCommit = byCommit(rw, in); ListMultimap<RevCommit, PatchSetData> byCommit = byCommit(rw, in);
if (byCommit.isEmpty()) { if (byCommit.isEmpty()) {
return ImmutableList.of(); return ImmutableList.of();
} else if (byCommit.size() == 1) { } else if (byCommit.size() == 1) {
@ -151,8 +151,8 @@ class WalkSorter {
// the input size is small enough that this is not an issue.) // the input size is small enough that this is not an issue.)
Set<RevCommit> commits = byCommit.keySet(); Set<RevCommit> commits = byCommit.keySet();
Multimap<RevCommit, RevCommit> children = collectChildren(commits); ListMultimap<RevCommit, RevCommit> children = collectChildren(commits);
Multimap<RevCommit, RevCommit> pending = ListMultimap<RevCommit, RevCommit> pending =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
Deque<RevCommit> todo = new ArrayDeque<>(); Deque<RevCommit> todo = new ArrayDeque<>();
@ -195,9 +195,9 @@ class WalkSorter {
} }
} }
private static Multimap<RevCommit, RevCommit> collectChildren( private static ListMultimap<RevCommit, RevCommit> collectChildren(
Set<RevCommit> commits) { Set<RevCommit> commits) {
Multimap<RevCommit, RevCommit> children = ListMultimap<RevCommit, RevCommit> children =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (RevCommit c : commits) { for (RevCommit c : commits) {
for (RevCommit p : c.getParents()) { for (RevCommit p : c.getParents()) {
@ -209,8 +209,9 @@ class WalkSorter {
return children; return children;
} }
private static int emit(RevCommit c, Multimap<RevCommit, PatchSetData> byCommit, private static int emit(RevCommit c,
List<PatchSetData> result, RevFlag done) { ListMultimap<RevCommit, PatchSetData> byCommit, List<PatchSetData> result,
RevFlag done) {
if (c.has(done)) { if (c.has(done)) {
return 0; return 0;
} }
@ -223,9 +224,9 @@ class WalkSorter {
return 0; return 0;
} }
private Multimap<RevCommit, PatchSetData> byCommit(RevWalk rw, private ListMultimap<RevCommit, PatchSetData> byCommit(RevWalk rw,
Collection<ChangeData> in) throws OrmException, IOException { Collection<ChangeData> in) throws OrmException, IOException {
Multimap<RevCommit, PatchSetData> byCommit = ListMultimap<RevCommit, PatchSetData> byCommit =
MultimapBuilder.hashKeys(in.size()).arrayListValues(1).build(); MultimapBuilder.hashKeys(in.size()).arrayListValues(1).build();
for (ChangeData cd : in) { for (ChangeData cd : in) {
PatchSet maxPs = null; PatchSet maxPs = null;

View File

@ -15,7 +15,7 @@
package com.google.gerrit.server.config; package com.google.gerrit.server.config;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import org.eclipse.jgit.revwalk.FooterLine; import org.eclipse.jgit.revwalk.FooterLine;
@ -37,8 +37,8 @@ public class TrackingFooters {
return trackingFooters.isEmpty(); return trackingFooters.isEmpty();
} }
public Multimap<String, String> extract(List<FooterLine> lines) { public ListMultimap<String, String> extract(List<FooterLine> lines) {
Multimap<String, String> r = ArrayListMultimap.create(); ListMultimap<String, String> r = ArrayListMultimap.create();
if (lines == null) { if (lines == null) {
return r; return r;
} }

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.edit;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.extensions.api.changes.RecipientType;
@ -171,7 +171,7 @@ public class ChangeEditUtil {
* @throws RestApiException * @throws RestApiException
*/ */
public void publish(final ChangeEdit edit, NotifyHandling notify, public void publish(final ChangeEdit edit, NotifyHandling notify,
Multimap<RecipientType, Account.Id> accountsToNotify) ListMultimap<RecipientType, Account.Id> accountsToNotify)
throws IOException, OrmException, RestApiException, UpdateException { throws IOException, OrmException, RestApiException, UpdateException {
Change change = edit.getChange(); Change change = edit.getChange();
try (Repository repo = gitManager.openRepository(change.getProject()); try (Repository repo = gitManager.openRepository(change.getProject());

View File

@ -17,8 +17,8 @@ package com.google.gerrit.server.events;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Comparator.comparing; import static java.util.Comparator.comparing;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes; import com.google.gerrit.common.data.LabelTypes;
@ -354,7 +354,8 @@ public class EventFactory {
return d; return d;
} }
public void addTrackingIds(ChangeAttribute a, Multimap<String, String> set) { public void addTrackingIds(ChangeAttribute a,
ListMultimap<String, String> set) {
if (!set.isEmpty()) { if (!set.isEmpty()) {
a.trackingIds = new ArrayList<>(set.size()); a.trackingIds = new ArrayList<>(set.size());
for (Map.Entry<String, Collection<String>> e : set.asMap().entrySet()) { for (Map.Entry<String, Collection<String>> e : set.asMap().entrySet()) {

View File

@ -15,7 +15,7 @@
package com.google.gerrit.server.git; package com.google.gerrit.server.git;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.extensions.api.changes.RecipientType;
@ -49,7 +49,7 @@ public class AbandonOp extends BatchUpdate.Op {
private final String msgTxt; private final String msgTxt;
private final NotifyHandling notifyHandling; private final NotifyHandling notifyHandling;
private final Multimap<RecipientType, Account.Id> accountsToNotify; private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
private final Account account; private final Account account;
private Change change; private Change change;
@ -61,7 +61,7 @@ public class AbandonOp extends BatchUpdate.Op {
@Assisted @Nullable Account account, @Assisted @Nullable Account account,
@Assisted @Nullable String msgTxt, @Assisted @Nullable String msgTxt,
@Assisted NotifyHandling notifyHandling, @Assisted NotifyHandling notifyHandling,
@Assisted Multimap<RecipientType, Account.Id> accountsToNotify); @Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify);
} }
@AssistedInject @AssistedInject
@ -73,7 +73,7 @@ public class AbandonOp extends BatchUpdate.Op {
@Assisted @Nullable Account account, @Assisted @Nullable Account account,
@Assisted @Nullable String msgTxt, @Assisted @Nullable String msgTxt,
@Assisted NotifyHandling notifyHandling, @Assisted NotifyHandling notifyHandling,
@Assisted Multimap<RecipientType, Account.Id> accountsToNotify) { @Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.abandonedSenderFactory = abandonedSenderFactory; this.abandonedSenderFactory = abandonedSenderFactory;
this.cmUtil = cmUtil; this.cmUtil = cmUtil;
this.psUtil = psUtil; this.psUtil = psUtil;

View File

@ -19,7 +19,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
@ -82,7 +81,7 @@ public class ChangeSet {
return changeData; return changeData;
} }
public Multimap<Branch.NameKey, ChangeData> changesByBranch() public ListMultimap<Branch.NameKey, ChangeData> changesByBranch()
throws OrmException { throws OrmException {
ListMultimap<Branch.NameKey, ChangeData> ret = ListMultimap<Branch.NameKey, ChangeData> ret =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.git; package com.google.gerrit.server.git;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.extensions.api.changes.RecipientType;
@ -46,7 +46,7 @@ public class EmailMerge implements Runnable, RequestContext {
public interface Factory { public interface Factory {
EmailMerge create(Project.NameKey project, Change.Id changeId, EmailMerge create(Project.NameKey project, Change.Id changeId,
Account.Id submitter, NotifyHandling notifyHandling, Account.Id submitter, NotifyHandling notifyHandling,
Multimap<RecipientType, Account.Id> accountsToNotify); ListMultimap<RecipientType, Account.Id> accountsToNotify);
} }
private final ExecutorService sendEmailsExecutor; private final ExecutorService sendEmailsExecutor;
@ -59,7 +59,7 @@ public class EmailMerge implements Runnable, RequestContext {
private final Change.Id changeId; private final Change.Id changeId;
private final Account.Id submitter; private final Account.Id submitter;
private final NotifyHandling notifyHandling; private final NotifyHandling notifyHandling;
private final Multimap<RecipientType, Account.Id> accountsToNotify; private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
private ReviewDb db; private ReviewDb db;
@ -73,7 +73,7 @@ public class EmailMerge implements Runnable, RequestContext {
@Assisted Change.Id changeId, @Assisted Change.Id changeId,
@Assisted @Nullable Account.Id submitter, @Assisted @Nullable Account.Id submitter,
@Assisted NotifyHandling notifyHandling, @Assisted NotifyHandling notifyHandling,
@Assisted Multimap<RecipientType, Account.Id> accountsToNotify) { @Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.sendEmailsExecutor = executor; this.sendEmailsExecutor = executor;
this.mergedSenderFactory = mergedSenderFactory; this.mergedSenderFactory = mergedSenderFactory;
this.schemaFactory = schemaFactory; this.schemaFactory = schemaFactory;

View File

@ -22,7 +22,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Multimaps; import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap; import com.google.common.collect.SetMultimap;
@ -103,16 +102,16 @@ public class GroupCollector {
List<String> lookup(PatchSet.Id psId) throws OrmException; List<String> lookup(PatchSet.Id psId) throws OrmException;
} }
private final Multimap<ObjectId, PatchSet.Id> patchSetsBySha; private final ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha;
private final Multimap<ObjectId, String> groups; private final ListMultimap<ObjectId, String> groups;
private final SetMultimap<String, String> groupAliases; private final SetMultimap<String, String> groupAliases;
private final Lookup groupLookup; private final Lookup groupLookup;
private boolean done; private boolean done;
public static GroupCollector create(Multimap<ObjectId, Ref> changeRefsById, public static GroupCollector create(ListMultimap<ObjectId, Ref> changeRefsById,
final ReviewDb db, final PatchSetUtil psUtil, ReviewDb db, PatchSetUtil psUtil, ChangeNotes.Factory notesFactory,
final ChangeNotes.Factory notesFactory, final Project.NameKey project) { Project.NameKey project) {
return new GroupCollector( return new GroupCollector(
transformRefs(changeRefsById), transformRefs(changeRefsById),
new Lookup() { new Lookup() {
@ -128,7 +127,7 @@ public class GroupCollector {
} }
public static GroupCollector createForSchemaUpgradeOnly( public static GroupCollector createForSchemaUpgradeOnly(
Multimap<ObjectId, Ref> changeRefsById, final ReviewDb db) { ListMultimap<ObjectId, Ref> changeRefsById, ReviewDb db) {
return new GroupCollector( return new GroupCollector(
transformRefs(changeRefsById), transformRefs(changeRefsById),
new Lookup() { new Lookup() {
@ -141,7 +140,7 @@ public class GroupCollector {
} }
private GroupCollector( private GroupCollector(
Multimap<ObjectId, PatchSet.Id> patchSetsBySha, ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha,
Lookup groupLookup) { Lookup groupLookup) {
this.patchSetsBySha = patchSetsBySha; this.patchSetsBySha = patchSetsBySha;
this.groupLookup = groupLookup; this.groupLookup = groupLookup;
@ -149,16 +148,16 @@ public class GroupCollector {
groupAliases = MultimapBuilder.hashKeys().hashSetValues().build(); groupAliases = MultimapBuilder.hashKeys().hashSetValues().build();
} }
private static Multimap<ObjectId, PatchSet.Id> transformRefs( private static ListMultimap<ObjectId, PatchSet.Id> transformRefs(
Multimap<ObjectId, Ref> refs) { ListMultimap<ObjectId, Ref> refs) {
return Multimaps.transformValues( return Multimaps.transformValues(
refs, r -> PatchSet.Id.fromRef(r.getName())); refs, r -> PatchSet.Id.fromRef(r.getName()));
} }
@VisibleForTesting @VisibleForTesting
GroupCollector( GroupCollector(
Multimap<ObjectId, PatchSet.Id> patchSetsBySha, ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha,
final ListMultimap<PatchSet.Id, String> groupLookup) { ListMultimap<PatchSet.Id, String> groupLookup) {
this( this(
patchSetsBySha, patchSetsBySha,
new Lookup() { new Lookup() {

View File

@ -21,12 +21,13 @@ import static java.util.Comparator.comparing;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
@ -109,7 +110,7 @@ public class MergeOp implements AutoCloseable {
private final ImmutableMap<Change.Id, ChangeData> changes; private final ImmutableMap<Change.Id, ChangeData> changes;
private final ImmutableSetMultimap<Branch.NameKey, Change.Id> byBranch; private final ImmutableSetMultimap<Branch.NameKey, Change.Id> byBranch;
private final Map<Change.Id, CodeReviewCommit> commits; private final Map<Change.Id, CodeReviewCommit> commits;
private final Multimap<Change.Id, String> problems; private final ListMultimap<Change.Id, String> problems;
private CommitStatus(ChangeSet cs) throws OrmException { private CommitStatus(ChangeSet cs) throws OrmException {
checkArgument(!cs.furtherHiddenChanges(), checkArgument(!cs.furtherHiddenChanges(),
@ -163,8 +164,8 @@ public class MergeOp implements AutoCloseable {
return problems.isEmpty(); return problems.isEmpty();
} }
public ImmutableMultimap<Change.Id, String> getProblems() { public ImmutableListMultimap<Change.Id, String> getProblems() {
return ImmutableMultimap.copyOf(problems); return ImmutableListMultimap.copyOf(problems);
} }
public List<SubmitRecord> getSubmitRecords(Change.Id id) { public List<SubmitRecord> getSubmitRecords(Change.Id id) {
@ -228,7 +229,7 @@ public class MergeOp implements AutoCloseable {
private CommitStatus commits; private CommitStatus commits;
private ReviewDb db; private ReviewDb db;
private SubmitInput submitInput; private SubmitInput submitInput;
private Multimap<RecipientType, Account.Id> accountsToNotify; private ListMultimap<RecipientType, Account.Id> accountsToNotify;
private Set<Project.NameKey> allProjects; private Set<Project.NameKey> allProjects;
private boolean dryrun; private boolean dryrun;
@ -452,7 +453,7 @@ public class MergeOp implements AutoCloseable {
logDebug("Beginning merge attempt on {}", cs); logDebug("Beginning merge attempt on {}", cs);
Map<Branch.NameKey, BranchBatch> toSubmit = new HashMap<>(); Map<Branch.NameKey, BranchBatch> toSubmit = new HashMap<>();
Multimap<Branch.NameKey, ChangeData> cbb; ListMultimap<Branch.NameKey, ChangeData> cbb;
try { try {
cbb = cs.changesByBranch(); cbb = cs.changesByBranch();
} catch (OrmException e) { } catch (OrmException e) {
@ -596,7 +597,7 @@ public class MergeOp implements AutoCloseable {
Collection<ChangeData> submitted) throws IntegrationException { Collection<ChangeData> submitted) throws IntegrationException {
logDebug("Validating {} changes", submitted.size()); logDebug("Validating {} changes", submitted.size());
List<ChangeData> toSubmit = new ArrayList<>(submitted.size()); List<ChangeData> toSubmit = new ArrayList<>(submitted.size());
Multimap<ObjectId, PatchSet.Id> revisions = getRevisions(or, submitted); SetMultimap<ObjectId, PatchSet.Id> revisions = getRevisions(or, submitted);
SubmitType submitType = null; SubmitType submitType = null;
ChangeData choseSubmitTypeFrom = null; ChangeData choseSubmitTypeFrom = null;
@ -696,7 +697,7 @@ public class MergeOp implements AutoCloseable {
return new AutoValue_MergeOp_BranchBatch(submitType, toSubmit); return new AutoValue_MergeOp_BranchBatch(submitType, toSubmit);
} }
private Multimap<ObjectId, PatchSet.Id> getRevisions(OpenRepo or, private SetMultimap<ObjectId, PatchSet.Id> getRevisions(OpenRepo or,
Collection<ChangeData> cds) throws IntegrationException { Collection<ChangeData> cds) throws IntegrationException {
try { try {
List<String> refNames = new ArrayList<>(cds.size()); List<String> refNames = new ArrayList<>(cds.size());
@ -706,7 +707,7 @@ public class MergeOp implements AutoCloseable {
refNames.add(c.currentPatchSetId().toRefName()); refNames.add(c.currentPatchSetId().toRefName());
} }
} }
Multimap<ObjectId, PatchSet.Id> revisions = SetMultimap<ObjectId, PatchSet.Id> revisions =
MultimapBuilder.hashKeys(cds.size()).hashSetValues(1).build(); MultimapBuilder.hashKeys(cds.size()).hashSetValues(1).build();
for (Map.Entry<String, Ref> e : or.repo.getRefDatabase().exactRef( for (Map.Entry<String, Ref> e : or.repo.getRefDatabase().exactRef(
refNames.toArray(new String[refNames.size()])).entrySet()) { refNames.toArray(new String[refNames.size()])).entrySet()) {

View File

@ -44,9 +44,7 @@ import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.collect.SortedSetMultimap; import com.google.common.collect.SortedSetMultimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
@ -325,7 +323,7 @@ public class ReceiveCommits {
private final Set<ObjectId> validCommits = new HashSet<>(); private final Set<ObjectId> validCommits = new HashSet<>();
private ListMultimap<Change.Id, Ref> refsByChange; private ListMultimap<Change.Id, Ref> refsByChange;
private SetMultimap<ObjectId, Ref> refsById; private ListMultimap<ObjectId, Ref> refsById;
private Map<String, Ref> allRefs; private Map<String, Ref> allRefs;
private final SubmoduleOp.Factory subOpFactory; private final SubmoduleOp.Factory subOpFactory;
@ -1325,8 +1323,8 @@ public class ReceiveCommits {
return new MailRecipients(reviewer, cc); return new MailRecipients(reviewer, cc);
} }
Multimap<RecipientType, Account.Id> getAccountsToNotify() { ListMultimap<RecipientType, Account.Id> getAccountsToNotify() {
Multimap<RecipientType, Account.Id> accountsToNotify = ListMultimap<RecipientType, Account.Id> accountsToNotify =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
accountsToNotify.putAll(RecipientType.TO, tos); accountsToNotify.putAll(RecipientType.TO, tos);
accountsToNotify.putAll(RecipientType.CC, ccs); accountsToNotify.putAll(RecipientType.CC, ccs);
@ -1673,8 +1671,9 @@ public class ReceiveCommits {
logDebug("Finding new and replaced changes"); logDebug("Finding new and replaced changes");
newChanges = new ArrayList<>(); newChanges = new ArrayList<>();
SetMultimap<ObjectId, Ref> existing = changeRefsById(); ListMultimap<ObjectId, Ref> existing = changeRefsById();
GroupCollector groupCollector = GroupCollector.create(changeRefsById(), db, psUtil, GroupCollector groupCollector = GroupCollector.create(
changeRefsById(), db, psUtil,
notesFactory, project.getNameKey()); notesFactory, project.getNameKey());
try { try {
@ -2527,7 +2526,7 @@ public class ReceiveCommits {
private void initChangeRefMaps() { private void initChangeRefMaps() {
if (refsByChange == null) { if (refsByChange == null) {
int estRefsPerChange = 4; int estRefsPerChange = 4;
refsById = MultimapBuilder.hashKeys().hashSetValues().build(); refsById = MultimapBuilder.hashKeys().arrayListValues().build();
refsByChange = refsByChange =
MultimapBuilder.hashKeys(allRefs.size() / estRefsPerChange) MultimapBuilder.hashKeys(allRefs.size() / estRefsPerChange)
.arrayListValues(estRefsPerChange) .arrayListValues(estRefsPerChange)
@ -2550,7 +2549,7 @@ public class ReceiveCommits {
return refsByChange; return refsByChange;
} }
private SetMultimap<ObjectId, Ref> changeRefsById() { private ListMultimap<ObjectId, Ref> changeRefsById() {
initChangeRefMaps(); initChangeRefMaps();
return refsById; return refsById;
} }
@ -2630,7 +2629,7 @@ public class ReceiveCommits {
if (!(parsedObject instanceof RevCommit)) { if (!(parsedObject instanceof RevCommit)) {
return; return;
} }
SetMultimap<ObjectId, Ref> existing = changeRefsById(); ListMultimap<ObjectId, Ref> existing = changeRefsById();
walk.markStart((RevCommit)parsedObject); walk.markStart((RevCommit)parsedObject);
markHeadsAsUninteresting(walk, cmd.getRefName()); markHeadsAsUninteresting(walk, cmd.getRefName());
int i = 0; int i = 0;
@ -2727,7 +2726,7 @@ public class ReceiveCommits {
rw.markUninteresting(rw.parseCommit(cmd.getOldId())); rw.markUninteresting(rw.parseCommit(cmd.getOldId()));
} }
SetMultimap<ObjectId, Ref> byCommit = changeRefsById(); ListMultimap<ObjectId, Ref> byCommit = changeRefsById();
Map<Change.Key, ChangeNotes> byKey = null; Map<Change.Key, ChangeNotes> byKey = null;
List<ReplaceRequest> replaceAndClose = new ArrayList<>(); List<ReplaceRequest> replaceAndClose = new ArrayList<>();

View File

@ -15,7 +15,6 @@
package com.google.gerrit.server.git; package com.google.gerrit.server.git;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap; import com.google.common.collect.SetMultimap;
import com.google.gerrit.common.data.SubscribeSection; import com.google.gerrit.common.data.SubscribeSection;
@ -115,7 +114,7 @@ public class SubmoduleOp {
// sorted version of affectedBranches // sorted version of affectedBranches
private final ImmutableSet<Branch.NameKey> sortedBranches; private final ImmutableSet<Branch.NameKey> sortedBranches;
// map of superproject branch and its submodule subscriptions // map of superproject branch and its submodule subscriptions
private final Multimap<Branch.NameKey, SubmoduleSubscription> targets; private final SetMultimap<Branch.NameKey, SubmoduleSubscription> targets;
// map of superproject and its branches which has submodule subscriptions // map of superproject and its branches which has submodule subscriptions
private final SetMultimap<Project.NameKey, Branch.NameKey> branchesByProject; private final SetMultimap<Project.NameKey, Branch.NameKey> branchesByProject;

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.git.strategy;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.extensions.api.changes.RecipientType;
@ -99,7 +99,7 @@ public abstract class SubmitStrategy {
Set<RevCommit> alreadyAccepted, Set<RevCommit> alreadyAccepted,
RequestId submissionId, RequestId submissionId,
NotifyHandling notifyHandling, NotifyHandling notifyHandling,
Multimap<RecipientType, Account.Id> accountsToNotify, ListMultimap<RecipientType, Account.Id> accountsToNotify,
SubmoduleOp submoduleOp, SubmoduleOp submoduleOp,
boolean dryrun); boolean dryrun);
} }
@ -133,7 +133,7 @@ public abstract class SubmitStrategy {
final RequestId submissionId; final RequestId submissionId;
final SubmitType submitType; final SubmitType submitType;
final NotifyHandling notifyHandling; final NotifyHandling notifyHandling;
final Multimap<RecipientType, Account.Id> accountsToNotify; final ListMultimap<RecipientType, Account.Id> accountsToNotify;
final SubmoduleOp submoduleOp; final SubmoduleOp submoduleOp;
final ProjectState project; final ProjectState project;
@ -172,7 +172,7 @@ public abstract class SubmitStrategy {
@Assisted RequestId submissionId, @Assisted RequestId submissionId,
@Assisted SubmitType submitType, @Assisted SubmitType submitType,
@Assisted NotifyHandling notifyHandling, @Assisted NotifyHandling notifyHandling,
@Assisted Multimap<RecipientType, Account.Id> accountsToNotify, @Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify,
@Assisted SubmoduleOp submoduleOp, @Assisted SubmoduleOp submoduleOp,
@Assisted boolean dryrun) { @Assisted boolean dryrun) {
this.accountCache = accountCache; this.accountCache = accountCache;

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.git.strategy; package com.google.gerrit.server.git.strategy;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.extensions.api.changes.RecipientType;
import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.extensions.client.SubmitType;
@ -59,7 +59,7 @@ public class SubmitStrategyFactory {
Branch.NameKey destBranch, IdentifiedUser caller, MergeTip mergeTip, Branch.NameKey destBranch, IdentifiedUser caller, MergeTip mergeTip,
CommitStatus commits, RequestId submissionId, CommitStatus commits, RequestId submissionId,
NotifyHandling notifyHandling, NotifyHandling notifyHandling,
Multimap<RecipientType, Account.Id> accountsToNotify, ListMultimap<RecipientType, Account.Id> accountsToNotify,
SubmoduleOp submoduleOp, boolean dryrun) throws IntegrationException { SubmoduleOp submoduleOp, boolean dryrun) throws IntegrationException {
SubmitStrategy.Arguments args = argsFactory.create(submitType, destBranch, SubmitStrategy.Arguments args = argsFactory.create(submitType, destBranch,
commits, rw, caller, mergeTip, inserter, repo, canMergeFlag, db, commits, rw, caller, mergeTip, inserter, repo, canMergeFlag, db,

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.group; package com.google.gerrit.server.group;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.data.GroupDescriptions; import com.google.gerrit.common.data.GroupDescriptions;
import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.common.data.GroupReference;
@ -70,7 +70,7 @@ public class GroupsCollection implements
} }
@Override @Override
public void setParams(Multimap<String, String> params) public void setParams(ListMultimap<String, String> params)
throws BadRequestException { throws BadRequestException {
if (params.containsKey("query") && params.containsKey("query2")) { if (params.containsKey("query") && params.containsKey("query2")) {
throw new BadRequestException( throw new BadRequestException(

View File

@ -23,8 +23,8 @@ import static org.eclipse.jgit.lib.RefDatabase.ALL;
import com.google.common.base.Stopwatch; import com.google.common.base.Stopwatch;
import com.google.common.collect.ComparisonChain; import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -217,7 +217,7 @@ public class AllChangesIndexer
return new Callable<Void>() { return new Callable<Void>() {
@Override @Override
public Void call() throws Exception { public Void call() throws Exception {
Multimap<ObjectId, ChangeData> byId = ListMultimap<ObjectId, ChangeData> byId =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
// TODO(dborowitz): Opening all repositories in a live server may be // TODO(dborowitz): Opening all repositories in a live server may be
// wasteful; see if we can determine which ones it is safe to close // wasteful; see if we can determine which ones it is safe to close
@ -260,7 +260,7 @@ public class AllChangesIndexer
private final ChangeIndexer indexer; private final ChangeIndexer indexer;
private final ThreeWayMergeStrategy mergeStrategy; private final ThreeWayMergeStrategy mergeStrategy;
private final AutoMerger autoMerger; private final AutoMerger autoMerger;
private final Multimap<ObjectId, ChangeData> byId; private final ListMultimap<ObjectId, ChangeData> byId;
private final ProgressMonitor done; private final ProgressMonitor done;
private final ProgressMonitor failed; private final ProgressMonitor failed;
private final PrintWriter verboseWriter; private final PrintWriter verboseWriter;
@ -269,7 +269,7 @@ public class AllChangesIndexer
private ProjectIndexer(ChangeIndexer indexer, private ProjectIndexer(ChangeIndexer indexer,
ThreeWayMergeStrategy mergeStrategy, ThreeWayMergeStrategy mergeStrategy,
AutoMerger autoMerger, AutoMerger autoMerger,
Multimap<ObjectId, ChangeData> changesByCommitId, ListMultimap<ObjectId, ChangeData> changesByCommitId,
Repository repo, Repository repo,
ProgressMonitor done, ProgressMonitor done,
ProgressMonitor failed, ProgressMonitor failed,

View File

@ -24,7 +24,6 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap; import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -110,7 +109,7 @@ public class StalenessChecker {
Change indexChange, Change indexChange,
@Nullable Change reviewDbChange, @Nullable Change reviewDbChange,
SetMultimap<Project.NameKey, RefState> states, SetMultimap<Project.NameKey, RefState> states,
Multimap<Project.NameKey, RefStatePattern> patterns) { ListMultimap<Project.NameKey, RefStatePattern> patterns) {
return reviewDbChangeIsStale(indexChange, reviewDbChange) return reviewDbChangeIsStale(indexChange, reviewDbChange)
|| refsAreStale(repoManager, id, states, patterns); || refsAreStale(repoManager, id, states, patterns);
} }
@ -119,7 +118,7 @@ public class StalenessChecker {
static boolean refsAreStale(GitRepositoryManager repoManager, static boolean refsAreStale(GitRepositoryManager repoManager,
Change.Id id, Change.Id id,
SetMultimap<Project.NameKey, RefState> states, SetMultimap<Project.NameKey, RefState> states,
Multimap<Project.NameKey, RefStatePattern> patterns) { ListMultimap<Project.NameKey, RefStatePattern> patterns) {
Set<Project.NameKey> projects = Set<Project.NameKey> projects =
Sets.union(states.keySet(), patterns.keySet()); Sets.union(states.keySet(), patterns.keySet());
@ -172,7 +171,7 @@ public class StalenessChecker {
return result; return result;
} }
private Multimap<Project.NameKey, RefStatePattern> parsePatterns( private ListMultimap<Project.NameKey, RefStatePattern> parsePatterns(
ChangeData cd) { ChangeData cd) {
return parsePatterns(cd.getRefStatePatterns()); return parsePatterns(cd.getRefStatePatterns());
} }
@ -197,7 +196,7 @@ public class StalenessChecker {
private static boolean refsAreStale(GitRepositoryManager repoManager, private static boolean refsAreStale(GitRepositoryManager repoManager,
Change.Id id, Project.NameKey project, Change.Id id, Project.NameKey project,
SetMultimap<Project.NameKey, RefState> allStates, SetMultimap<Project.NameKey, RefState> allStates,
Multimap<Project.NameKey, RefStatePattern> allPatterns) { ListMultimap<Project.NameKey, RefStatePattern> allPatterns) {
try (Repository repo = repoManager.openRepository(project)) { try (Repository repo = repoManager.openRepository(project)) {
Set<RefState> states = allStates.get(project); Set<RefState> states = allStates.get(project);
for (RefState state : states) { for (RefState state : states) {

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.mail.send; package com.google.gerrit.server.mail.send;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.errors.EmailException; import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.extensions.api.changes.RecipientType;
@ -310,7 +310,7 @@ public abstract class ChangeEmail extends NotificationEmail {
// BCC anyone who has starred this change // BCC anyone who has starred this change
// and remove anyone who has ignored this change. // and remove anyone who has ignored this change.
// //
Multimap<Account.Id, String> stars = ListMultimap<Account.Id, String> stars =
args.starredChangesUtil.byChangeFromIndex(change.getId()); args.starredChangesUtil.byChangeFromIndex(change.getId());
for (Map.Entry<Account.Id, Collection<String>> e : for (Map.Entry<Account.Id, Collection<String>> e :
stars.asMap().entrySet()) { stars.asMap().entrySet()) {

View File

@ -20,7 +20,7 @@ import static com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailSt
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.errors.EmailException; import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.extensions.api.changes.RecipientType;
@ -76,7 +76,7 @@ public abstract class OutgoingEmail {
private Address smtpFromAddress; private Address smtpFromAddress;
private StringBuilder textBody; private StringBuilder textBody;
private StringBuilder htmlBody; private StringBuilder htmlBody;
private Multimap<RecipientType, Account.Id> accountsToNotify = private ListMultimap<RecipientType, Account.Id> accountsToNotify =
ImmutableListMultimap.of(); ImmutableListMultimap.of();
protected VelocityContext velocityContext; protected VelocityContext velocityContext;
protected Map<String, Object> soyContext; protected Map<String, Object> soyContext;
@ -101,7 +101,7 @@ public abstract class OutgoingEmail {
} }
public void setAccountsToNotify( public void setAccountsToNotify(
Multimap<RecipientType, Account.Id> accountsToNotify) { ListMultimap<RecipientType, Account.Id> accountsToNotify) {
this.accountsToNotify = checkNotNull(accountsToNotify); this.accountsToNotify = checkNotNull(accountsToNotify);
} }

View File

@ -37,9 +37,9 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
@ -562,7 +562,7 @@ public class ChangeBundle {
// but easy to reason about. // but easy to reason about.
List<ChangeMessage> as = new LinkedList<>(bundleA.filterChangeMessages()); List<ChangeMessage> as = new LinkedList<>(bundleA.filterChangeMessages());
Multimap<ChangeMessageCandidate, ChangeMessage> bs = ListMultimap<ChangeMessageCandidate, ChangeMessage> bs =
LinkedListMultimap.create(); LinkedListMultimap.create();
for (ChangeMessage b : bundleB.filterChangeMessages()) { for (ChangeMessage b : bundleB.filterChangeMessages()) {
bs.put(ChangeMessageCandidate.create(b), b); bs.put(ChangeMessageCandidate.create(b), b);

View File

@ -21,7 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
@ -525,7 +525,7 @@ public class ChangeNoteUtil {
* side. * side.
* @param out output stream to write to. * @param out output stream to write to.
*/ */
void buildNote(Multimap<Integer, Comment> comments, void buildNote(ListMultimap<Integer, Comment> comments,
OutputStream out) { OutputStream out) {
if (comments.isEmpty()) { if (comments.isEmpty()) {
return; return;

View File

@ -40,8 +40,8 @@ import com.google.common.base.Splitter;
import com.google.common.collect.HashBasedTable; import com.google.common.collect.HashBasedTable;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.collect.Table; import com.google.common.collect.Table;
@ -130,7 +130,7 @@ class ChangeNotesParser {
private final List<Account.Id> allPastReviewers; private final List<Account.Id> allPastReviewers;
private final List<ReviewerStatusUpdate> reviewerUpdates; private final List<ReviewerStatusUpdate> reviewerUpdates;
private final List<SubmitRecord> submitRecords; private final List<SubmitRecord> submitRecords;
private final Multimap<RevId, Comment> comments; private final ListMultimap<RevId, Comment> comments;
private final Map<PatchSet.Id, PatchSet> patchSets; private final Map<PatchSet.Id, PatchSet> patchSets;
private final Set<PatchSet.Id> deletedPatchSets; private final Set<PatchSet.Id> deletedPatchSets;
private final Map<PatchSet.Id, PatchSetState> patchSetStates; private final Map<PatchSet.Id, PatchSetState> patchSetStates;
@ -138,7 +138,8 @@ class ChangeNotesParser {
private final Map<ApprovalKey, PatchSetApproval> approvals; private final Map<ApprovalKey, PatchSetApproval> approvals;
private final List<PatchSetApproval> bufferedApprovals; private final List<PatchSetApproval> bufferedApprovals;
private final List<ChangeMessage> allChangeMessages; private final List<ChangeMessage> allChangeMessages;
private final Multimap<PatchSet.Id, ChangeMessage> changeMessagesByPatchSet; private final ListMultimap<PatchSet.Id, ChangeMessage>
changeMessagesByPatchSet;
// Non-final private members filled in during the parsing process. // Non-final private members filled in during the parsing process.
private String branch; private String branch;
@ -248,8 +249,8 @@ class ChangeNotesParser {
return null; return null;
} }
private Multimap<PatchSet.Id, PatchSetApproval> buildApprovals() { private ListMultimap<PatchSet.Id, PatchSetApproval> buildApprovals() {
Multimap<PatchSet.Id, PatchSetApproval> result = ListMultimap<PatchSet.Id, PatchSetApproval> result =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (PatchSetApproval a : approvals.values()) { for (PatchSetApproval a : approvals.values()) {
if (!patchSets.containsKey(a.getPatchSetId())) { if (!patchSets.containsKey(a.getPatchSetId())) {
@ -283,7 +284,7 @@ class ChangeNotesParser {
return Lists.reverse(allChangeMessages); return Lists.reverse(allChangeMessages);
} }
private Multimap<PatchSet.Id, ChangeMessage> buildMessagesByPatchSet() { private ListMultimap<PatchSet.Id, ChangeMessage> buildMessagesByPatchSet() {
for (Collection<ChangeMessage> v : for (Collection<ChangeMessage> v :
changeMessagesByPatchSet.asMap().values()) { changeMessagesByPatchSet.asMap().values()) {
Collections.reverse((List<ChangeMessage>) v); Collections.reverse((List<ChangeMessage>) v);

View File

@ -22,7 +22,7 @@ import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@ -95,14 +95,14 @@ public abstract class ChangeNotesState {
@Nullable Set<Account.Id> pastAssignees, @Nullable Set<Account.Id> pastAssignees,
@Nullable Set<String> hashtags, @Nullable Set<String> hashtags,
Map<PatchSet.Id, PatchSet> patchSets, Map<PatchSet.Id, PatchSet> patchSets,
Multimap<PatchSet.Id, PatchSetApproval> approvals, ListMultimap<PatchSet.Id, PatchSetApproval> approvals,
ReviewerSet reviewers, ReviewerSet reviewers,
List<Account.Id> allPastReviewers, List<Account.Id> allPastReviewers,
List<ReviewerStatusUpdate> reviewerUpdates, List<ReviewerStatusUpdate> reviewerUpdates,
List<SubmitRecord> submitRecords, List<SubmitRecord> submitRecords,
List<ChangeMessage> allChangeMessages, List<ChangeMessage> allChangeMessages,
Multimap<PatchSet.Id, ChangeMessage> changeMessagesByPatchSet, ListMultimap<PatchSet.Id, ChangeMessage> changeMessagesByPatchSet,
Multimap<RevId, Comment> publishedComments) { ListMultimap<RevId, Comment> publishedComments) {
if (hashtags == null) { if (hashtags == null) {
hashtags = ImmutableSet.of(); hashtags = ImmutableSet.of();
} }

View File

@ -21,7 +21,7 @@ import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.metrics.Timer1; import com.google.gerrit.metrics.Timer1;
@ -167,7 +167,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
revisionNoteMap = RevisionNoteMap.parse( revisionNoteMap = RevisionNoteMap.parse(
args.noteUtil, getChangeId(), reader, NoteMap.read(reader, tipCommit), args.noteUtil, getChangeId(), reader, NoteMap.read(reader, tipCommit),
PatchLineComment.Status.DRAFT); PatchLineComment.Status.DRAFT);
Multimap<RevId, Comment> cs = ListMultimap<RevId, Comment> cs =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (ChangeRevisionNote rn : revisionNoteMap.revisionNotes.values()) { for (ChangeRevisionNote rn : revisionNoteMap.revisionNotes.values()) {
for (Comment c : rn.getComments()) { for (Comment c : rn.getComments()) {

View File

@ -18,8 +18,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.gerrit.server.CommentsUtil.COMMENT_ORDER; import static com.google.gerrit.server.CommentsUtil.COMMENT_ORDER;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.reviewdb.client.Comment; import com.google.gerrit.reviewdb.client.Comment;
import com.google.gerrit.reviewdb.client.RevId; import com.google.gerrit.reviewdb.client.RevId;
@ -112,8 +112,8 @@ class RevisionNoteBuilder {
this.pushCert = pushCert; this.pushCert = pushCert;
} }
private Multimap<Integer, Comment> buildCommentMap() { private ListMultimap<Integer, Comment> buildCommentMap() {
Multimap<Integer, Comment> all = ListMultimap<Integer, Comment> all =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (Comment c : baseComments) { for (Comment c : baseComments) {
@ -131,7 +131,7 @@ class RevisionNoteBuilder {
private void buildNoteJson(ChangeNoteUtil noteUtil, OutputStream out) private void buildNoteJson(ChangeNoteUtil noteUtil, OutputStream out)
throws IOException { throws IOException {
Multimap<Integer, Comment> comments = buildCommentMap(); ListMultimap<Integer, Comment> comments = buildCommentMap();
if (comments.isEmpty() && pushCert == null) { if (comments.isEmpty() && pushCert == null) {
return; return;
} }

View File

@ -15,7 +15,7 @@
package com.google.gerrit.server.notedb; package com.google.gerrit.server.notedb;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
@ -95,7 +95,7 @@ public class RobotCommentNotes extends AbstractChangeNotes<RobotCommentNotes> {
ObjectReader reader = handle.walk().getObjectReader(); ObjectReader reader = handle.walk().getObjectReader();
revisionNoteMap = RevisionNoteMap.parseRobotComments(args.noteUtil, reader, revisionNoteMap = RevisionNoteMap.parseRobotComments(args.noteUtil, reader,
NoteMap.read(reader, tipCommit)); NoteMap.read(reader, tipCommit));
Multimap<RevId, RobotComment> cs = ListMultimap<RevId, RobotComment> cs =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (RobotCommentsRevisionNote rn : for (RobotCommentsRevisionNote rn :
revisionNoteMap.revisionNotes.values()) { revisionNoteMap.revisionNotes.values()) {

View File

@ -25,9 +25,9 @@ import static java.util.stream.Collectors.toList;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -299,7 +299,7 @@ public class ChangeRebuilderImpl extends ChangeRebuilder {
// We will rebuild all events, except for draft comments, in buckets based // We will rebuild all events, except for draft comments, in buckets based
// on author and timestamp. // on author and timestamp.
List<Event> events = new ArrayList<>(); List<Event> events = new ArrayList<>();
Multimap<Account.Id, DraftCommentEvent> draftCommentEvents = ListMultimap<Account.Id, DraftCommentEvent> draftCommentEvents =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
events.addAll(getHashtagsEvents(change, manager)); events.addAll(getHashtagsEvents(change, manager));

View File

@ -19,7 +19,7 @@ import static com.google.gerrit.server.plugins.AutoRegisterUtil.calculateBindAnn
import static com.google.gerrit.server.plugins.PluginGuiceEnvironment.is; import static com.google.gerrit.server.plugins.PluginGuiceEnvironment.is;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.annotations.Export; import com.google.gerrit.extensions.annotations.Export;
import com.google.gerrit.extensions.annotations.ExtensionPoint; import com.google.gerrit.extensions.annotations.ExtensionPoint;
import com.google.gerrit.extensions.annotations.Listen; import com.google.gerrit.extensions.annotations.Listen;
@ -54,7 +54,7 @@ class AutoRegisterModules {
private final ModuleGenerator httpGen; private final ModuleGenerator httpGen;
private Set<Class<?>> sysSingletons; private Set<Class<?>> sysSingletons;
private Multimap<TypeLiteral<?>, Class<?>> sysListen; private ListMultimap<TypeLiteral<?>, Class<?>> sysListen;
private String initJs; private String initJs;
Module sysModule; Module sysModule;

View File

@ -19,9 +19,9 @@ import static com.google.common.collect.Iterables.transform;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.IO;
@ -67,7 +67,7 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
String pluginName, Iterable<Class<? extends Annotation>> annotations) String pluginName, Iterable<Class<? extends Annotation>> annotations)
throws InvalidPluginException { throws InvalidPluginException {
Set<String> descriptors = new HashSet<>(); Set<String> descriptors = new HashSet<>();
Multimap<String, JarScanner.ClassData> rawMap = ListMultimap<String, JarScanner.ClassData> rawMap =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
Map<Class<? extends Annotation>, String> classObjToClassDescr = Map<Class<? extends Annotation>, String> classObjToClassDescr =
new HashMap<>(); new HashMap<>();

View File

@ -24,8 +24,8 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.google.gerrit.extensions.annotations.PluginName; import com.google.gerrit.extensions.annotations.PluginName;
@ -399,7 +399,7 @@ public class PluginLoader implements LifecycleListener {
} }
public synchronized void rescan() { public synchronized void rescan() {
Multimap<String, Path> pluginsFiles = prunePlugins(pluginsDir); SetMultimap<String, Path> pluginsFiles = prunePlugins(pluginsDir);
if (pluginsFiles.isEmpty()) { if (pluginsFiles.isEmpty()) {
return; return;
} }
@ -478,7 +478,7 @@ public class PluginLoader implements LifecycleListener {
return sortedPlugins; return sortedPlugins;
} }
private void syncDisabledPlugins(Multimap<String, Path> jars) { private void syncDisabledPlugins(SetMultimap<String, Path> jars) {
stopRemovedPlugins(jars); stopRemovedPlugins(jars);
dropRemovedDisabledPlugins(jars); dropRemovedDisabledPlugins(jars);
} }
@ -525,7 +525,7 @@ public class PluginLoader implements LifecycleListener {
} }
} }
private void stopRemovedPlugins(Multimap<String, Path> jars) { private void stopRemovedPlugins(SetMultimap<String, Path> jars) {
Set<String> unload = Sets.newHashSet(running.keySet()); Set<String> unload = Sets.newHashSet(running.keySet());
for (Map.Entry<String, Collection<Path>> entry : jars.asMap().entrySet()) { for (Map.Entry<String, Collection<Path>> entry : jars.asMap().entrySet()) {
for (Path path : entry.getValue()) { for (Path path : entry.getValue()) {
@ -539,7 +539,7 @@ public class PluginLoader implements LifecycleListener {
} }
} }
private void dropRemovedDisabledPlugins(Multimap<String, Path> jars) { private void dropRemovedDisabledPlugins(SetMultimap<String, Path> jars) {
Set<String> unload = Sets.newHashSet(disabled.keySet()); Set<String> unload = Sets.newHashSet(disabled.keySet());
for (Map.Entry<String, Collection<Path>> entry : jars.asMap().entrySet()) { for (Map.Entry<String, Collection<Path>> entry : jars.asMap().entrySet()) {
for (Path path : entry.getValue()) { for (Path path : entry.getValue()) {
@ -644,7 +644,7 @@ public class PluginLoader implements LifecycleListener {
// Only one active plugin per plugin name can exist for each plugin name. // Only one active plugin per plugin name can exist for each plugin name.
// Filter out disabled plugins and transform the multimap to a map // Filter out disabled plugins and transform the multimap to a map
private static Map<String, Path> filterDisabled( private static Map<String, Path> filterDisabled(
Multimap<String, Path> pluginPaths) { SetMultimap<String, Path> pluginPaths) {
Map<String, Path> activePlugins = Maps.newHashMapWithExpectedSize( Map<String, Path> activePlugins = Maps.newHashMapWithExpectedSize(
pluginPaths.keys().size()); pluginPaths.keys().size());
for (String name : pluginPaths.keys()) { for (String name : pluginPaths.keys()) {
@ -667,9 +667,9 @@ public class PluginLoader implements LifecycleListener {
// //
// NOTE: Bear in mind that the plugin name can be reassigned after load by the // NOTE: Bear in mind that the plugin name can be reassigned after load by the
// Server plugin provider. // Server plugin provider.
public Multimap<String, Path> prunePlugins(Path pluginsDir) { public SetMultimap<String, Path> prunePlugins(Path pluginsDir) {
List<Path> pluginPaths = scanPathsInPluginsDirectory(pluginsDir); List<Path> pluginPaths = scanPathsInPluginsDirectory(pluginsDir);
Multimap<String, Path> map; SetMultimap<String, Path> map;
map = asMultimap(pluginPaths); map = asMultimap(pluginPaths);
for (String plugin : map.keySet()) { for (String plugin : map.keySet()) {
Collection<Path> files = map.asMap().get(plugin); Collection<Path> files = map.asMap().get(plugin);
@ -735,8 +735,8 @@ public class PluginLoader implements LifecycleListener {
return null; return null;
} }
private Multimap<String, Path> asMultimap(List<Path> plugins) { private SetMultimap<String, Path> asMultimap(List<Path> plugins) {
Multimap<String, Path> map = LinkedHashMultimap.create(); SetMultimap<String, Path> map = LinkedHashMultimap.create();
for (Path srcPath : plugins) { for (Path srcPath : plugins) {
map.put(getPluginName(srcPath), srcPath); map.put(getPluginName(srcPath), srcPath);
} }

View File

@ -18,9 +18,9 @@ import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.gerrit.server.project.RefPattern.isRE; import static com.google.gerrit.server.project.RefPattern.isRE;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.AccessSection; import com.google.gerrit.common.data.AccessSection;
@ -118,7 +118,7 @@ public class PermissionCollection {
HashMap<String, List<PermissionRule>> permissions = new HashMap<>(); HashMap<String, List<PermissionRule>> permissions = new HashMap<>();
HashMap<String, List<PermissionRule>> overridden = new HashMap<>(); HashMap<String, List<PermissionRule>> overridden = new HashMap<>();
Map<PermissionRule, ProjectRef> ruleProps = Maps.newIdentityHashMap(); Map<PermissionRule, ProjectRef> ruleProps = Maps.newIdentityHashMap();
Multimap<Project.NameKey, String> exclusivePermissionsByProject = ListMultimap<Project.NameKey, String> exclusivePermissionsByProject =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (AccessSection section : sections) { for (AccessSection section : sections) {
Project.NameKey project = sectionToProject.get(section); Project.NameKey project = sectionToProject.get(section);

View File

@ -24,12 +24,10 @@ import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.common.data.SubmitTypeRecord; import com.google.gerrit.common.data.SubmitTypeRecord;
@ -352,7 +350,7 @@ public class ChangeData {
private Map<Account.Id, Ref> draftsByUser; private Map<Account.Id, Ref> draftsByUser;
@Deprecated @Deprecated
private Set<Account.Id> starredByUser; private Set<Account.Id> starredByUser;
private ImmutableMultimap<Account.Id, String> stars; private ImmutableListMultimap<Account.Id, String> stars;
private ImmutableMap<Account.Id, StarRef> starRefs; private ImmutableMap<Account.Id, StarRef> starRefs;
private ReviewerSet reviewers; private ReviewerSet reviewers;
private List<ReviewerStatusUpdate> reviewerUpdates; private List<ReviewerStatusUpdate> reviewerUpdates;
@ -1230,13 +1228,13 @@ public class ChangeData {
this.starredByUser = starredByUser; this.starredByUser = starredByUser;
} }
public ImmutableMultimap<Account.Id, String> stars() throws OrmException { public ImmutableListMultimap<Account.Id, String> stars() throws OrmException {
if (stars == null) { if (stars == null) {
if (!lazyLoad) { if (!lazyLoad) {
return ImmutableMultimap.of(); return ImmutableListMultimap.of();
} }
ImmutableMultimap.Builder<Account.Id, String> b = ImmutableListMultimap.Builder<Account.Id, String> b =
ImmutableMultimap.builder(); ImmutableListMultimap.builder();
for (Map.Entry<Account.Id, StarRef> e : starRefs().entrySet()) { for (Map.Entry<Account.Id, StarRef> e : starRefs().entrySet()) {
b.putAll(e.getKey(), e.getValue().labels()); b.putAll(e.getKey(), e.getValue().labels());
} }
@ -1245,8 +1243,8 @@ public class ChangeData {
return stars; return stars;
} }
public void setStars(Multimap<Account.Id, String> stars) { public void setStars(ListMultimap<Account.Id, String> stars) {
this.stars = ImmutableMultimap.copyOf(stars); this.stars = ImmutableListMultimap.copyOf(stars);
} }
public ImmutableMap<Account.Id, StarRef> starRefs() throws OrmException { public ImmutableMap<Account.Id, StarRef> starRefs() throws OrmException {

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.schema;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.SetMultimap; import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -100,9 +100,9 @@ public class Schema_108 extends SchemaVersion {
} }
} }
Multimap<ObjectId, Ref> changeRefsBySha = ListMultimap<ObjectId, Ref> changeRefsBySha =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
Multimap<ObjectId, PatchSet.Id> patchSetsBySha = ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
for (Ref ref : refdb.getRefs(RefNames.REFS_CHANGES).values()) { for (Ref ref : refdb.getRefs(RefNames.REFS_CHANGES).values()) {
ObjectId id = ref.getObjectId(); ObjectId id = ref.getObjectId();
@ -132,7 +132,7 @@ public class Schema_108 extends SchemaVersion {
} }
private static void updateGroups(ReviewDb db, GroupCollector collector, private static void updateGroups(ReviewDb db, GroupCollector collector,
Multimap<ObjectId, PatchSet.Id> patchSetsBySha) throws OrmException { ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha) throws OrmException {
Map<PatchSet.Id, PatchSet> patchSets = Map<PatchSet.Id, PatchSet> patchSets =
db.patchSets().toMap(db.patchSets().get(patchSetsBySha.values())); db.patchSets().toMap(db.patchSets().get(patchSetsBySha.values()));
for (Map.Entry<ObjectId, Collection<String>> e for (Map.Entry<ObjectId, Collection<String>> e

View File

@ -14,7 +14,7 @@
package com.google.gerrit.server.schema; package com.google.gerrit.server.schema;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
@ -57,7 +57,7 @@ public class Schema_123 extends SchemaVersion {
@Override @Override
protected void migrateData(ReviewDb db, UpdateUI ui) protected void migrateData(ReviewDb db, UpdateUI ui)
throws OrmException, SQLException { throws OrmException, SQLException {
Multimap<Account.Id, Change.Id> imports = ListMultimap<Account.Id, Change.Id> imports =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement(); try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
ResultSet rs = stmt.executeQuery( ResultSet rs = stmt.executeQuery(

View File

@ -17,7 +17,7 @@ package com.google.gerrit.server.schema;
import static java.util.Comparator.comparing; import static java.util.Comparator.comparing;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@ -71,7 +71,7 @@ public class Schema_124 extends SchemaVersion {
@Override @Override
protected void migrateData(ReviewDb db, UpdateUI ui) protected void migrateData(ReviewDb db, UpdateUI ui)
throws OrmException, SQLException { throws OrmException, SQLException {
Multimap<Account.Id, AccountSshKey> imports = ListMultimap<Account.Id, AccountSshKey> imports =
MultimapBuilder.hashKeys().arrayListValues().build(); MultimapBuilder.hashKeys().arrayListValues().build();
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement(); try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
ResultSet rs = stmt.executeQuery( ResultSet rs = stmt.executeQuery(

View File

@ -16,7 +16,7 @@ package com.google.gerrit.server.schema;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
@ -73,7 +73,7 @@ public class Schema_139 extends SchemaVersion {
@Override @Override
protected void migrateData(ReviewDb db, UpdateUI ui) protected void migrateData(ReviewDb db, UpdateUI ui)
throws OrmException, SQLException { throws OrmException, SQLException {
Multimap<Account.Id, ProjectWatch> imports = ArrayListMultimap.create(); ListMultimap<Account.Id, ProjectWatch> imports = ArrayListMultimap.create();
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement(); try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
ResultSet rs = stmt.executeQuery( ResultSet rs = stmt.executeQuery(
"SELECT " "SELECT "
@ -183,4 +183,4 @@ public class Schema_139 extends SchemaVersion {
abstract ProjectWatch build(); abstract ProjectWatch build();
} }
} }
} }

View File

@ -17,9 +17,8 @@ package com.google.gerrit.server.git;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap; import com.google.common.collect.SortedSetMultimap;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
@ -47,7 +46,7 @@ public class GroupCollectorTest {
RevCommit branchTip = tr.commit().create(); RevCommit branchTip = tr.commit().create();
RevCommit a = tr.commit().parent(branchTip).create(); RevCommit a = tr.commit().parent(branchTip).create();
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(a, branchTip), newWalk(a, branchTip),
patchSets(), patchSets(),
groups()); groups());
@ -62,7 +61,7 @@ public class GroupCollectorTest {
RevCommit a = tr.commit().parent(branchTip).create(); RevCommit a = tr.commit().parent(branchTip).create();
RevCommit b = tr.commit().parent(a).create(); RevCommit b = tr.commit().parent(a).create();
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(b, branchTip), newWalk(b, branchTip),
patchSets(), patchSets(),
groups()); groups());
@ -79,7 +78,7 @@ public class GroupCollectorTest {
RevCommit b = tr.commit().parent(a).create(); RevCommit b = tr.commit().parent(a).create();
String group = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; String group = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(b, branchTip), newWalk(b, branchTip),
patchSets().put(a, psId(1, 1)), patchSets().put(a, psId(1, 1)),
groups().put(psId(1, 1), group)); groups().put(psId(1, 1), group));
@ -95,7 +94,7 @@ public class GroupCollectorTest {
RevCommit a = tr.commit().parent(branchTip).create(); RevCommit a = tr.commit().parent(branchTip).create();
RevCommit b = tr.commit().parent(a).create(); RevCommit b = tr.commit().parent(a).create();
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(b, branchTip), newWalk(b, branchTip),
patchSets().put(a, psId(1, 1)), patchSets().put(a, psId(1, 1)),
groups()); groups());
@ -111,7 +110,7 @@ public class GroupCollectorTest {
RevCommit b = tr.commit().parent(branchTip).create(); RevCommit b = tr.commit().parent(branchTip).create();
RevCommit m = tr.commit().parent(a).parent(b).create(); RevCommit m = tr.commit().parent(a).parent(b).create();
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(m, branchTip), newWalk(m, branchTip),
patchSets(), patchSets(),
groups()); groups());
@ -129,7 +128,7 @@ public class GroupCollectorTest {
RevCommit m = tr.commit().parent(a).parent(b).create(); RevCommit m = tr.commit().parent(a).parent(b).create();
String group = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; String group = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(m, branchTip), newWalk(m, branchTip),
patchSets().put(b, psId(1, 1)), patchSets().put(b, psId(1, 1)),
groups().put(psId(1, 1), group)); groups().put(psId(1, 1), group));
@ -150,7 +149,7 @@ public class GroupCollectorTest {
String group1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; String group1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
String group2 = "1234567812345678123456781234567812345678"; String group2 = "1234567812345678123456781234567812345678";
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(m, branchTip), newWalk(m, branchTip),
patchSets() patchSets()
.put(a, psId(1, 1)) .put(a, psId(1, 1))
@ -176,7 +175,7 @@ public class GroupCollectorTest {
String group1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; String group1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
String group2a = "1234567812345678123456781234567812345678"; String group2a = "1234567812345678123456781234567812345678";
String group2b = "ef123456ef123456ef123456ef123456ef123456"; String group2b = "ef123456ef123456ef123456ef123456ef123456";
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(m, branchTip), newWalk(m, branchTip),
patchSets() patchSets()
.put(a, psId(1, 1)) .put(a, psId(1, 1))
@ -202,7 +201,7 @@ public class GroupCollectorTest {
RevCommit m = tr.commit().parent(branchTip).parent(a).create(); RevCommit m = tr.commit().parent(branchTip).parent(a).create();
String group = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; String group = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(m, branchTip), newWalk(m, branchTip),
patchSets().put(a, psId(1, 1)), patchSets().put(a, psId(1, 1)),
groups().put(psId(1, 1), group)); groups().put(psId(1, 1), group));
@ -218,7 +217,7 @@ public class GroupCollectorTest {
RevCommit a = tr.commit().parent(branchTip).create(); RevCommit a = tr.commit().parent(branchTip).create();
RevCommit m = tr.commit().parent(branchTip).parent(a).create(); RevCommit m = tr.commit().parent(branchTip).parent(a).create();
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(m, branchTip), newWalk(m, branchTip),
patchSets(), patchSets(),
groups()); groups());
@ -237,7 +236,7 @@ public class GroupCollectorTest {
RevCommit m1 = tr.commit().parent(b).parent(c).create(); RevCommit m1 = tr.commit().parent(b).parent(c).create();
RevCommit m2 = tr.commit().parent(a).parent(m1).create(); RevCommit m2 = tr.commit().parent(a).parent(m1).create();
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(m2, branchTip), newWalk(m2, branchTip),
patchSets(), patchSets(),
groups()); groups());
@ -259,7 +258,7 @@ public class GroupCollectorTest {
assertThat(m.getParentCount()).isEqualTo(2); assertThat(m.getParentCount()).isEqualTo(2);
assertThat(m.getParent(0)).isEqualTo(m.getParent(1)); assertThat(m.getParent(0)).isEqualTo(m.getParent(1));
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(m, branchTip), newWalk(m, branchTip),
patchSets(), patchSets(),
groups()); groups());
@ -279,7 +278,7 @@ public class GroupCollectorTest {
String group1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; String group1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
String group2 = "1234567812345678123456781234567812345678"; String group2 = "1234567812345678123456781234567812345678";
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
newWalk(m, branchTip), newWalk(m, branchTip),
patchSets() patchSets()
.put(a, psId(1, 1)) .put(a, psId(1, 1))
@ -307,7 +306,7 @@ public class GroupCollectorTest {
rw.markStart(rw.parseCommit(d)); rw.markStart(rw.parseCommit(d));
// Schema upgrade case: all commits are existing patch sets, but none have // Schema upgrade case: all commits are existing patch sets, but none have
// groups assigned yet. // groups assigned yet.
Multimap<ObjectId, String> groups = collectGroups( SortedSetMultimap<ObjectId, String> groups = collectGroups(
rw, rw,
patchSets() patchSets()
.put(branchTip, psId(1, 1)) .put(branchTip, psId(1, 1))
@ -339,9 +338,9 @@ public class GroupCollectorTest {
return rw; return rw;
} }
private static Multimap<ObjectId, String> collectGroups( private static SortedSetMultimap<ObjectId, String> collectGroups(
RevWalk rw, RevWalk rw,
ImmutableMultimap.Builder<ObjectId, PatchSet.Id> patchSetsBySha, ImmutableListMultimap.Builder<ObjectId, PatchSet.Id> patchSetsBySha,
ImmutableListMultimap.Builder<PatchSet.Id, String> groupLookup) ImmutableListMultimap.Builder<PatchSet.Id, String> groupLookup)
throws Exception { throws Exception {
GroupCollector gc = GroupCollector gc =
@ -355,8 +354,9 @@ public class GroupCollectorTest {
// Helper methods for constructing various map arguments, to avoid lots of // Helper methods for constructing various map arguments, to avoid lots of
// type specifications. // type specifications.
private static ImmutableMultimap.Builder<ObjectId, PatchSet.Id> patchSets() { private static ImmutableListMultimap.Builder<ObjectId, PatchSet.Id>
return ImmutableMultimap.builder(); patchSets() {
return ImmutableListMultimap.builder();
} }
private static ImmutableListMultimap.Builder<PatchSet.Id, String> groups() { private static ImmutableListMultimap.Builder<PatchSet.Id, String> groups() {

View File

@ -21,7 +21,7 @@ import static com.google.gerrit.testutil.TestChanges.newChange;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@ -194,7 +194,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id1.name()), P1, RefState.create(ref1, id1.name()),
P2, RefState.create(ref2, id2.name())), P2, RefState.create(ref2, id2.name())),
ImmutableMultimap.of())) ImmutableListMultimap.of()))
.isFalse(); .isFalse();
// Wrong ref value. // Wrong ref value.
@ -204,7 +204,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, SHA1), P1, RefState.create(ref1, SHA1),
P2, RefState.create(ref2, id2.name())), P2, RefState.create(ref2, id2.name())),
ImmutableMultimap.of())) ImmutableListMultimap.of()))
.isTrue(); .isTrue();
// Swapped repos. // Swapped repos.
@ -214,7 +214,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id2.name()), P1, RefState.create(ref1, id2.name()),
P2, RefState.create(ref2, id1.name())), P2, RefState.create(ref2, id1.name())),
ImmutableMultimap.of())) ImmutableListMultimap.of()))
.isTrue(); .isTrue();
// Two refs in same repo, not stale. // Two refs in same repo, not stale.
@ -227,7 +227,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id1.name()), P1, RefState.create(ref1, id1.name()),
P1, RefState.create(ref3, id3.name())), P1, RefState.create(ref3, id3.name())),
ImmutableMultimap.of())) ImmutableListMultimap.of()))
.isFalse(); .isFalse();
// Ignore ref not mentioned. // Ignore ref not mentioned.
@ -236,7 +236,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
repoManager, C, repoManager, C,
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id1.name())), P1, RefState.create(ref1, id1.name())),
ImmutableMultimap.of())) ImmutableListMultimap.of()))
.isFalse(); .isFalse();
// One ref wrong. // One ref wrong.
@ -246,7 +246,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id1.name()), P1, RefState.create(ref1, id1.name()),
P1, RefState.create(ref3, SHA1)), P1, RefState.create(ref3, SHA1)),
ImmutableMultimap.of())) ImmutableListMultimap.of()))
.isTrue(); .isTrue();
} }
@ -261,7 +261,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
repoManager, C, repoManager, C,
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id1.name())), P1, RefState.create(ref1, id1.name())),
ImmutableMultimap.of( ImmutableListMultimap.of(
P1, RefStatePattern.create("refs/heads/*")))) P1, RefStatePattern.create("refs/heads/*"))))
.isFalse(); .isFalse();
@ -273,7 +273,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
repoManager, C, repoManager, C,
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id1.name())), P1, RefState.create(ref1, id1.name())),
ImmutableMultimap.of( ImmutableListMultimap.of(
P1, RefStatePattern.create("refs/heads/*")))) P1, RefStatePattern.create("refs/heads/*"))))
.isTrue(); .isTrue();
assertThat( assertThat(
@ -282,7 +282,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id1.name()), P1, RefState.create(ref1, id1.name()),
P1, RefState.create(ref2, id2.name())), P1, RefState.create(ref2, id2.name())),
ImmutableMultimap.of( ImmutableListMultimap.of(
P1, RefStatePattern.create("refs/heads/*")))) P1, RefStatePattern.create("refs/heads/*"))))
.isFalse(); .isFalse();
} }
@ -299,7 +299,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
repoManager, C, repoManager, C,
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id1.name())), P1, RefState.create(ref1, id1.name())),
ImmutableMultimap.of( ImmutableListMultimap.of(
P1, RefStatePattern.create("refs/*/foo")))) P1, RefStatePattern.create("refs/*/foo"))))
.isFalse(); .isFalse();
@ -311,7 +311,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
repoManager, C, repoManager, C,
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id1.name())), P1, RefState.create(ref1, id1.name())),
ImmutableMultimap.of( ImmutableListMultimap.of(
P1, RefStatePattern.create("refs/*/foo")))) P1, RefStatePattern.create("refs/*/foo"))))
.isTrue(); .isTrue();
assertThat( assertThat(
@ -320,7 +320,7 @@ public class StalenessCheckerTest extends GerritBaseTests {
ImmutableSetMultimap.of( ImmutableSetMultimap.of(
P1, RefState.create(ref1, id1.name()), P1, RefState.create(ref1, id1.name()),
P1, RefState.create(ref3, id3.name())), P1, RefState.create(ref3, id3.name())),
ImmutableMultimap.of( ImmutableListMultimap.of(
P1, RefStatePattern.create("refs/*/foo")))) P1, RefStatePattern.create("refs/*/foo"))))
.isFalse(); .isFalse();
} }

View File

@ -26,7 +26,6 @@ import static org.junit.Assert.fail;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableTable; import com.google.common.collect.ImmutableTable;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -350,7 +349,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes = newNotes(c); notes = newNotes(c);
assertThat(notes.getApprovals()).containsExactlyEntriesIn( assertThat(notes.getApprovals()).containsExactlyEntriesIn(
ImmutableMultimap.of( ImmutableListMultimap.of(
psa.getPatchSetId(), psa.getPatchSetId(),
new PatchSetApproval(psa.getKey(), (short) 0, update.getWhen()))); new PatchSetApproval(psa.getKey(), (short) 0, update.getWhen())));
} }
@ -375,7 +374,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes = newNotes(c); notes = newNotes(c);
assertThat(notes.getApprovals()).containsExactlyEntriesIn( assertThat(notes.getApprovals()).containsExactlyEntriesIn(
ImmutableMultimap.of( ImmutableListMultimap.of(
psa.getPatchSetId(), psa.getPatchSetId(),
new PatchSetApproval(psa.getKey(), (short) 0, update.getWhen()))); new PatchSetApproval(psa.getKey(), (short) 0, update.getWhen())));
@ -1452,7 +1451,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertThat(notes.getComments()) assertThat(notes.getComments())
.isEqualTo(ImmutableMultimap.of(revId, comment)); .isEqualTo(ImmutableListMultimap.of(revId, comment));
} }
@Test @Test
@ -1472,7 +1471,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertThat(notes.getComments()) assertThat(notes.getComments())
.isEqualTo(ImmutableMultimap.of(revId, comment)); .isEqualTo(ImmutableListMultimap.of(revId, comment));
} }
@Test @Test
@ -1492,7 +1491,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertThat(notes.getComments()) assertThat(notes.getComments())
.isEqualTo(ImmutableMultimap.of(revId, comment)); .isEqualTo(ImmutableListMultimap.of(revId, comment));
} }
@Test @Test
@ -1512,7 +1511,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertThat(notes.getComments()) assertThat(notes.getComments())
.isEqualTo(ImmutableMultimap.of(revId, comment)); .isEqualTo(ImmutableListMultimap.of(revId, comment));
} }
@Test @Test
@ -1822,7 +1821,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
} }
} }
assertThat(notes.getComments()).isEqualTo( assertThat(notes.getComments()).isEqualTo(
ImmutableMultimap.of( ImmutableListMultimap.of(
revId, comment1, revId, comment1,
revId, comment2, revId, comment2,
revId, comment3)); revId, comment3));
@ -1879,7 +1878,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
} }
} }
assertThat(notes.getComments()) assertThat(notes.getComments())
.isEqualTo(ImmutableMultimap.of(revId, comment)); .isEqualTo(ImmutableListMultimap.of(revId, comment));
} }
@Test @Test
@ -1934,7 +1933,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
} }
} }
assertThat(notes.getComments()) assertThat(notes.getComments())
.isEqualTo(ImmutableMultimap.of(new RevId(comment.revId), comment)); .isEqualTo(ImmutableListMultimap.of(new RevId(comment.revId), comment));
} }
@Test @Test
@ -1969,7 +1968,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
assertThat(newNotes(c).getComments()).containsExactlyEntriesIn( assertThat(newNotes(c).getComments()).containsExactlyEntriesIn(
ImmutableMultimap.of( ImmutableListMultimap.of(
new RevId(rev1), commentForBase, new RevId(rev1), commentForBase,
new RevId(rev2), commentForPS)); new RevId(rev2), commentForPS));
} }
@ -2004,7 +2003,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
assertThat(newNotes(c).getComments()).containsExactlyEntriesIn( assertThat(newNotes(c).getComments()).containsExactlyEntriesIn(
ImmutableMultimap.of( ImmutableListMultimap.of(
new RevId(rev), comment1, new RevId(rev), comment1,
new RevId(rev), comment2)).inOrder(); new RevId(rev), comment2)).inOrder();
} }
@ -2039,7 +2038,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
assertThat(newNotes(c).getComments()).containsExactlyEntriesIn( assertThat(newNotes(c).getComments()).containsExactlyEntriesIn(
ImmutableMultimap.of( ImmutableListMultimap.of(
new RevId(rev), comment1, new RevId(rev), comment1,
new RevId(rev), comment2)).inOrder(); new RevId(rev), comment2)).inOrder();
} }
@ -2077,7 +2076,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
assertThat(newNotes(c).getComments()).containsExactlyEntriesIn( assertThat(newNotes(c).getComments()).containsExactlyEntriesIn(
ImmutableMultimap.of( ImmutableListMultimap.of(
new RevId(rev1), comment1, new RevId(rev1), comment1,
new RevId(rev2), comment2)); new RevId(rev2), comment2));
} }
@ -2103,7 +2102,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertThat(notes.getDraftComments(otherUserId)).containsExactlyEntriesIn( assertThat(notes.getDraftComments(otherUserId)).containsExactlyEntriesIn(
ImmutableMultimap.of(new RevId(rev), comment1)); ImmutableListMultimap.of(new RevId(rev), comment1));
assertThat(notes.getComments()).isEmpty(); assertThat(notes.getComments()).isEmpty();
update = newUpdate(c, otherUser); update = newUpdate(c, otherUser);
@ -2114,7 +2113,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes = newNotes(c); notes = newNotes(c);
assertThat(notes.getDraftComments(otherUserId)).isEmpty(); assertThat(notes.getDraftComments(otherUserId)).isEmpty();
assertThat(notes.getComments()).containsExactlyEntriesIn( assertThat(notes.getComments()).containsExactlyEntriesIn(
ImmutableMultimap.of(new RevId(rev), comment1)); ImmutableListMultimap.of(new RevId(rev), comment1));
} }
@Test @Test
@ -2146,7 +2145,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertThat(notes.getDraftComments(otherUserId)).containsExactlyEntriesIn( assertThat(notes.getDraftComments(otherUserId)).containsExactlyEntriesIn(
ImmutableMultimap.of( ImmutableListMultimap.of(
new RevId(rev), comment1, new RevId(rev), comment1,
new RevId(rev), comment2)).inOrder(); new RevId(rev), comment2)).inOrder();
assertThat(notes.getComments()).isEmpty(); assertThat(notes.getComments()).isEmpty();
@ -2159,9 +2158,9 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes = newNotes(c); notes = newNotes(c);
assertThat(notes.getDraftComments(otherUserId)).containsExactlyEntriesIn( assertThat(notes.getDraftComments(otherUserId)).containsExactlyEntriesIn(
ImmutableMultimap.of(new RevId(rev), comment2)); ImmutableListMultimap.of(new RevId(rev), comment2));
assertThat(notes.getComments()).containsExactlyEntriesIn( assertThat(notes.getComments()).containsExactlyEntriesIn(
ImmutableMultimap.of(new RevId(rev), comment1)); ImmutableListMultimap.of(new RevId(rev), comment1));
} }
@Test @Test
@ -2194,7 +2193,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
assertThat(notes.getDraftComments(otherUserId)).containsExactlyEntriesIn( assertThat(notes.getDraftComments(otherUserId)).containsExactlyEntriesIn(
ImmutableMultimap.of( ImmutableListMultimap.of(
new RevId(rev1), baseComment, new RevId(rev1), baseComment,
new RevId(rev2), psComment)); new RevId(rev2), psComment));
assertThat(notes.getComments()).isEmpty(); assertThat(notes.getComments()).isEmpty();
@ -2210,7 +2209,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
notes = newNotes(c); notes = newNotes(c);
assertThat(notes.getDraftComments(otherUserId)).isEmpty(); assertThat(notes.getDraftComments(otherUserId)).isEmpty();
assertThat(notes.getComments()).containsExactlyEntriesIn( assertThat(notes.getComments()).containsExactlyEntriesIn(
ImmutableMultimap.of( ImmutableListMultimap.of(
new RevId(rev1), baseComment, new RevId(rev1), baseComment,
new RevId(rev2), psComment)); new RevId(rev2), psComment));
} }
@ -2373,7 +2372,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
assertThat(newNotes(c).getComments()).containsExactlyEntriesIn( assertThat(newNotes(c).getComments()).containsExactlyEntriesIn(
ImmutableMultimap.of(new RevId(rev), comment)); ImmutableListMultimap.of(new RevId(rev), comment));
} }
@Test @Test
@ -2393,7 +2392,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.commit(); update.commit();
assertThat(newNotes(c).getComments()).containsExactlyEntriesIn( assertThat(newNotes(c).getComments()).containsExactlyEntriesIn(
ImmutableMultimap.of(new RevId(rev), comment)); ImmutableListMultimap.of(new RevId(rev), comment));
} }
@Test @Test

View File

@ -18,7 +18,7 @@ import static com.google.gerrit.server.plugins.AutoRegisterUtil.calculateBindAnn
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.extensions.annotations.Export; import com.google.gerrit.extensions.annotations.Export;
import com.google.gerrit.server.plugins.InvalidPluginException; import com.google.gerrit.server.plugins.InvalidPluginException;
import com.google.gerrit.server.plugins.ModuleGenerator; import com.google.gerrit.server.plugins.ModuleGenerator;
@ -36,7 +36,8 @@ class SshAutoRegisterModuleGenerator
extends AbstractModule extends AbstractModule
implements ModuleGenerator { implements ModuleGenerator {
private final Map<String, Class<Command>> commands = new HashMap<>(); private final Map<String, Class<Command>> commands = new HashMap<>();
private final Multimap<TypeLiteral<?>, Class<?>> listeners = LinkedListMultimap.create(); private final ListMultimap<TypeLiteral<?>, Class<?>> listeners =
LinkedListMultimap.create();
private CommandName command; private CommandName command;
@Override @Override

View File

@ -15,7 +15,7 @@
package com.google.gerrit.sshd; package com.google.gerrit.sshd;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.audit.AuditService; import com.google.gerrit.audit.AuditService;
import com.google.gerrit.audit.SshAuditEvent; import com.google.gerrit.audit.SshAuditEvent;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
@ -156,14 +156,14 @@ class SshLog implements LifecycleListener {
audit(context.get(), status, dcmd); audit(context.get(), status, dcmd);
} }
private Multimap<String, ?> extractParameters(DispatchCommand dcmd) { private ListMultimap<String, ?> extractParameters(DispatchCommand dcmd) {
if (dcmd == null) { if (dcmd == null) {
return ArrayListMultimap.create(0, 0); return ArrayListMultimap.create(0, 0);
} }
String[] cmdArgs = dcmd.getArguments(); String[] cmdArgs = dcmd.getArguments();
String paramName = null; String paramName = null;
int argPos = 0; int argPos = 0;
Multimap<String, String> parms = ArrayListMultimap.create(); ListMultimap<String, String> parms = ArrayListMultimap.create();
for (int i = 2; i < cmdArgs.length; i++) { for (int i = 2; i < cmdArgs.length; i++) {
String arg = cmdArgs[i]; String arg = cmdArgs[i];
// -- stop parameters parsing // -- stop parameters parsing
@ -258,7 +258,8 @@ class SshLog implements LifecycleListener {
audit(ctx, result, extractWhat(cmd), extractParameters(cmd)); audit(ctx, result, extractWhat(cmd), extractParameters(cmd));
} }
private void audit(Context ctx, Object result, String cmd, Multimap<String, ?> params) { private void audit(Context ctx, Object result, String cmd,
ListMultimap<String, ?> params) {
String sessionId; String sessionId;
CurrentUser currentUser; CurrentUser currentUser;
long created; long created;

View File

@ -35,9 +35,9 @@
package com.google.gerrit.util.cli; package com.google.gerrit.util.cli;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
@ -224,7 +224,7 @@ public class CmdLineParser {
public void parseOptionMap(Map<String, String[]> parameters) public void parseOptionMap(Map<String, String[]> parameters)
throws CmdLineException { throws CmdLineException {
Multimap<String, String> map = LinkedHashMultimap.create(); ListMultimap<String, String> map = ArrayListMultimap.create();
for (Map.Entry<String, String[]> ent : parameters.entrySet()) { for (Map.Entry<String, String[]> ent : parameters.entrySet()) {
for (String val : ent.getValue()) { for (String val : ent.getValue()) {
map.put(ent.getKey(), val); map.put(ent.getKey(), val);
@ -233,7 +233,7 @@ public class CmdLineParser {
parseOptionMap(map); parseOptionMap(map);
} }
public void parseOptionMap(Multimap<String, String> params) public void parseOptionMap(ListMultimap<String, String> params)
throws CmdLineException { throws CmdLineException {
List<String> tmp = Lists.newArrayListWithCapacity(2 * params.size()); List<String> tmp = Lists.newArrayListWithCapacity(2 * params.size());
for (final String key : params.keySet()) { for (final String key : params.keySet()) {

@ -1 +1 @@
Subproject commit 860742125749aec5444bfa44bb727153c2649893 Subproject commit ea6c8c3949cecfd6547ce1e97d2dddbb2669e827

@ -1 +1 @@
Subproject commit 0ed3b13df0b4f88c67ece722e56e554f8f38e83a Subproject commit 66f08f2460ba89b6827f4e456be1c1a948a718aa