Materialize IdentifiedUser deps in BatchUpdate
When executing BatchUpdates from a receive commit, materialise the user dependent objects so that it can be passed over to other threads for delayed execution outside the current scope. P.S. This fixes Gerrit master breakages caused by OutOfScopeException. Change-Id: Ic463ddaeb5d9c90573a3a4639523f214125aaaad
This commit is contained in:
@@ -424,6 +424,28 @@ public class IdentifiedUser extends CurrentUser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a materialized copy of the user with all dependencies.
|
||||
*
|
||||
* Invoke all providers and factories of dependent objects and store the
|
||||
* references to a copy of the current identified user.
|
||||
*
|
||||
* @return copy of the identified user
|
||||
*/
|
||||
public IdentifiedUser materializedCopy() {
|
||||
final CapabilityControl capabilities = getCapabilities();
|
||||
return new IdentifiedUser(new CapabilityControl.Factory() {
|
||||
|
||||
@Override
|
||||
public CapabilityControl create(CurrentUser user) {
|
||||
return capabilities;
|
||||
}
|
||||
}, authConfig, realm, anonymousCowardName,
|
||||
Providers.of(canonicalUrl.get()), accountCache, groupBackend,
|
||||
disableReverseDnsLookup, Providers.of(remotePeerProvider.get()), state,
|
||||
realUser);
|
||||
}
|
||||
|
||||
private String getHost(final InetAddress in) {
|
||||
if (Boolean.FALSE.equals(disableReverseDnsLookup)) {
|
||||
return in.getCanonicalHostName();
|
||||
|
||||
@@ -825,8 +825,9 @@ public class ReceiveCommits {
|
||||
return;
|
||||
}
|
||||
|
||||
try (BatchUpdate bu = batchUpdateFactory.create(db,
|
||||
magicBranch.dest.getParentKey(), user, TimeUtil.nowTs());
|
||||
try (BatchUpdate bu =
|
||||
batchUpdateFactory.create(db, magicBranch.dest.getParentKey(),
|
||||
user.materializedCopy(), TimeUtil.nowTs());
|
||||
ObjectInserter ins = repo.newObjectInserter()) {
|
||||
bu.setRepository(repo, rp.getRevWalk(), ins)
|
||||
.updateChangesInParallel();
|
||||
|
||||
Reference in New Issue
Block a user