EventUtil: Exclude some more ListChangesOptions

Change-Id: I0e449efdbda593bc7bda698919948cd6baa4f1fb
This commit is contained in:
Dave Borowitz
2017-03-06 15:03:07 -05:00
parent 7769e59e81
commit 43e8c476f8

View File

@@ -14,6 +14,8 @@
package com.google.gerrit.server.extensions.events; 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.client.ListChangesOption;
import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.common.ApprovalInfo; import com.google.gerrit.extensions.common.ApprovalInfo;
@@ -43,6 +45,23 @@ import org.slf4j.LoggerFactory;
public class EventUtil { public class EventUtil {
private static final Logger log = LoggerFactory.getLogger(EventUtil.class); private static final Logger log = LoggerFactory.getLogger(EventUtil.class);
private static final ImmutableSet<ListChangesOption> CHANGE_OPTIONS;
static {
EnumSet<ListChangesOption> 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 ChangeData.Factory changeDataFactory;
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final ChangeJson changeJson; private final ChangeJson changeJson;
@@ -54,9 +73,7 @@ public class EventUtil {
Provider<ReviewDb> db) { Provider<ReviewDb> db) {
this.changeDataFactory = changeDataFactory; this.changeDataFactory = changeDataFactory;
this.db = db; this.db = db;
EnumSet<ListChangesOption> opts = EnumSet.allOf(ListChangesOption.class); this.changeJson = changeJsonFactory.create(CHANGE_OPTIONS);
opts.remove(ListChangesOption.CHECK);
this.changeJson = changeJsonFactory.create(opts);
} }
public ChangeInfo changeInfo(Change change) throws OrmException { public ChangeInfo changeInfo(Change change) throws OrmException {