Allow plugins to contribute a value to the change ETag computation

Plugins can affect the result of the get change / get change details
REST endpoints by:

* providing plugin defined attributes to the 'plugins' field in
  ChangeInfo
* implementing a SubmitRule which affects the computation of
  'submittable' field in ChangeInfo

If the plugin defined part of ChangeInfo depends on plugin specific
data, callers that use change ETags to avoid unneeded recomputations of
ChangeInfos may see outdated plugin attributes and/or outdated
submittable information, because a ChangeInfo is only reloaded if the
change ETag changes.

By implementating the new ChangeETagComputation interface plugins can
now contribute to the change ETag computation and thus ensure that the
ETag changes when the plugin data was changed. This way it can be
ensured that callers do not see outdated ChangeInfos.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I358e3d4fb2145a164ec1387fc1b40778959ad41e
This commit is contained in:
Edwin Kempin
2019-07-22 14:57:40 +02:00
parent f5d3e947fa
commit 96915b72dd
5 changed files with 162 additions and 0 deletions

View File

@@ -102,6 +102,7 @@ import com.google.gerrit.server.cache.CacheRemovalListener;
import com.google.gerrit.server.change.AbandonOp;
import com.google.gerrit.server.change.AccountPatchReviewStore;
import com.google.gerrit.server.change.ChangeAttributeFactory;
import com.google.gerrit.server.change.ChangeETagComputation;
import com.google.gerrit.server.change.ChangeFinder;
import com.google.gerrit.server.change.ChangeJson;
import com.google.gerrit.server.change.ChangeKindCacheImpl;
@@ -388,6 +389,7 @@ public class GerritGlobalModule extends FactoryModule {
DynamicSet.setOf(binder(), PerformanceLogger.class);
DynamicSet.setOf(binder(), RequestListener.class);
DynamicSet.bind(binder(), RequestListener.class).to(TraceRequestListener.class);
DynamicSet.setOf(binder(), ChangeETagComputation.class);
DynamicMap.mapOf(binder(), MailFilter.class);
bind(MailFilter.class).annotatedWith(Exports.named("ListMailFilter")).to(ListMailFilter.class);