Make collections in AccountState immutable
The account cache stores AccountState objects. If the collections in AccountState are mutable callers can polute the cache by making updates to the collections in AccountState without updating the underlying storage. Change-Id: I1141fd8211d4a081c92efe0848d90efe174487e4 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.server.account;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.account.WatchConfig.NotifyType;
|
||||
@@ -52,7 +53,7 @@ public class WatchConfigTest implements ValidationError.Sink {
|
||||
+ "[project \"otherProject\"]\n"
|
||||
+ " notify = [NEW_PATCHSETS]\n"
|
||||
+ " notify = * [NEW_PATCHSETS, ALL_COMMENTS]\n");
|
||||
Map<ProjectWatchKey, Set<NotifyType>> projectWatches =
|
||||
Map<ProjectWatchKey, ImmutableSet<NotifyType>> projectWatches =
|
||||
WatchConfig.parse(new Account.Id(1000000), cfg, this);
|
||||
|
||||
assertThat(validationErrors).isEmpty();
|
||||
|
||||
@@ -21,6 +21,8 @@ import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -30,8 +32,6 @@ import com.google.gerrit.server.config.AllUsersName;
|
||||
import com.google.gerrit.server.config.AllUsersNameProvider;
|
||||
import com.google.gerrit.server.mail.Address;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
@@ -388,8 +388,8 @@ public class FromAddressGeneratorProviderTest {
|
||||
return new AccountState(
|
||||
new AllUsersName(AllUsersNameProvider.DEFAULT),
|
||||
account,
|
||||
Collections.emptySet(),
|
||||
new HashMap<>(),
|
||||
ImmutableSet.of(),
|
||||
ImmutableMap.of(),
|
||||
GeneralPreferencesInfo.defaults());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user