From 43e8c476f89d930ede4ab2f3b40dee9c8ed9c7f8 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Mon, 6 Mar 2017 15:03:07 -0500 Subject: [PATCH] EventUtil: Exclude some more ListChangesOptions Change-Id: I0e449efdbda593bc7bda698919948cd6baa4f1fb --- .../server/extensions/events/EventUtil.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/extensions/events/EventUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/extensions/events/EventUtil.java index 887ce57866..f367e23219 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/extensions/events/EventUtil.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/extensions/events/EventUtil.java @@ -14,6 +14,8 @@ package com.google.gerrit.server.extensions.events; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.common.ApprovalInfo; @@ -43,6 +45,23 @@ import org.slf4j.LoggerFactory; public class EventUtil { private static final Logger log = LoggerFactory.getLogger(EventUtil.class); + private static final ImmutableSet CHANGE_OPTIONS; + + static { + EnumSet opts = EnumSet.allOf(ListChangesOption.class); + + // Some options, like actions, are expensive to compute because they potentially have to walk + // lots of history and inspect lots of other changes. + opts.remove(ListChangesOption.CHANGE_ACTIONS); + opts.remove(ListChangesOption.CURRENT_ACTIONS); + + // CHECK suppresses some exceptions on corrupt changes, which is not appropriate for passing + // through the event system as we would rather let them propagate. + opts.remove(ListChangesOption.CHECK); + + CHANGE_OPTIONS = Sets.immutableEnumSet(opts); + } + private final ChangeData.Factory changeDataFactory; private final Provider db; private final ChangeJson changeJson; @@ -54,9 +73,7 @@ public class EventUtil { Provider db) { this.changeDataFactory = changeDataFactory; this.db = db; - EnumSet opts = EnumSet.allOf(ListChangesOption.class); - opts.remove(ListChangesOption.CHECK); - this.changeJson = changeJsonFactory.create(opts); + this.changeJson = changeJsonFactory.create(CHANGE_OPTIONS); } public ChangeInfo changeInfo(Change change) throws OrmException {