Consistently annotate changeCache as @Nullable
The changeCache is null when in the context of BatchProgramModule.
The only consumer of changeCache, VisibleRefFilter, is prepared to
handle a null value, so in all code paths it is okay for it to be
null.
This makes reindex work again. Regression introduced in
a758640bc3
(VisibleRefFilter: Avoid
touching the database for drafts, 2016-06-03):
$ java -jar buck-out/gen/gerrit/gerrit.war reindex -d ../gerrit-testsite
[...]
Reindexing changes: projects: 66% (2/3)[2016-06-06 16:18:36,781] [Index-Batch-3] WARN com.google.gerrit.server.index.change.AllChangesIndexer : Failed to index change 18
com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) null returned by binding at com.google.gerrit.pgm.util.BatchProgramModule.configure(BatchProgramModule.java:126)
but parameter 8 of com.google.gerrit.server.project.ProjectControl.<init>() is not @Nullable
while locating com.google.gerrit.server.git.SearchingChangeCacheImpl
for parameter 8 at com.google.gerrit.server.project.ProjectControl.<init>(ProjectControl.java:177)
while locating com.google.gerrit.server.project.ProjectControl annotated with @com.google.inject.internal.UniqueAnnotations$Internal(value=4)
Reported-by: Viktar Donich <viktard@google.com>
Change-Id: Ia0ca0e0e153c9f357e5ebc6edf4b1962a2490f2d
This commit is contained in:
parent
7bf09b4e76
commit
b273cfd04d
@ -16,6 +16,7 @@ package com.google.gerrit.acceptance;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.acceptance.InProcessProtocol.Context;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.Capable;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@ -212,7 +213,7 @@ class InProcessProtocol extends TestProtocol<Context> {
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
private final Provider<CurrentUser> userProvider;
|
||||
private final TagCache tagCache;
|
||||
private final SearchingChangeCacheImpl changeCache;
|
||||
@Nullable private final SearchingChangeCacheImpl changeCache;
|
||||
private final ProjectControl.GenericFactory projectControlFactory;
|
||||
private final ChangeNotes.Factory changeNotesFactory;
|
||||
private final TransferConfig transferConfig;
|
||||
@ -225,7 +226,7 @@ class InProcessProtocol extends TestProtocol<Context> {
|
||||
Provider<ReviewDb> dbProvider,
|
||||
Provider<CurrentUser> userProvider,
|
||||
TagCache tagCache,
|
||||
SearchingChangeCacheImpl changeCache,
|
||||
@Nullable SearchingChangeCacheImpl changeCache,
|
||||
ProjectControl.GenericFactory projectControlFactory,
|
||||
ChangeNotes.Factory changeNotesFactory,
|
||||
TransferConfig transferConfig,
|
||||
|
@ -21,6 +21,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.AcceptanceTestRequestScope;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
@ -61,6 +62,7 @@ public class VisibleRefFilterIT extends AbstractDaemonTest {
|
||||
private ProjectControl.GenericFactory projectControlFactory;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
private SearchingChangeCacheImpl changeCache;
|
||||
|
||||
@Inject
|
||||
|
@ -16,6 +16,7 @@ package com.google.gerrit.httpd;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.Capable;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@ -225,13 +226,13 @@ public class GitOverHttpServlet extends GitServlet {
|
||||
private final Provider<ReviewDb> db;
|
||||
private final TagCache tagCache;
|
||||
private final ChangeNotes.Factory changeNotesFactory;
|
||||
private final SearchingChangeCacheImpl changeCache;
|
||||
@Nullable private final SearchingChangeCacheImpl changeCache;
|
||||
private final UploadValidators.Factory uploadValidatorsFactory;
|
||||
|
||||
@Inject
|
||||
UploadFilter(Provider<ReviewDb> db, TagCache tagCache,
|
||||
ChangeNotes.Factory changeNotesFactory,
|
||||
SearchingChangeCacheImpl changeCache,
|
||||
@Nullable SearchingChangeCacheImpl changeCache,
|
||||
UploadValidators.Factory uploadValidatorsFactory) {
|
||||
this.db = db;
|
||||
this.tagCache = tagCache;
|
||||
|
@ -373,7 +373,7 @@ public class ReceiveCommits {
|
||||
GitRepositoryManager repoManager,
|
||||
TagCache tagCache,
|
||||
AccountCache accountCache,
|
||||
SearchingChangeCacheImpl changeCache,
|
||||
@Nullable SearchingChangeCacheImpl changeCache,
|
||||
ChangesCollection changes,
|
||||
ChangeInserter.Factory changeInserterFactory,
|
||||
CommitValidators.Factory commitValidatorsFactory,
|
||||
|
@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.api.projects.TagInfo;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
@ -54,7 +55,7 @@ public class ListTags implements RestReadView<ProjectResource> {
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
private final TagCache tagCache;
|
||||
private final ChangeNotes.Factory changeNotesFactory;
|
||||
private final SearchingChangeCacheImpl changeCache;
|
||||
@Nullable private final SearchingChangeCacheImpl changeCache;
|
||||
|
||||
@Option(name = "--limit", aliases = {"-n"}, metaVar = "CNT", usage = "maximum number of tags to list")
|
||||
public void setLimit(int limit) {
|
||||
@ -86,7 +87,7 @@ public class ListTags implements RestReadView<ProjectResource> {
|
||||
Provider<ReviewDb> dbProvider,
|
||||
TagCache tagCache,
|
||||
ChangeNotes.Factory changeNotesFactory,
|
||||
SearchingChangeCacheImpl changeCache) {
|
||||
@Nullable SearchingChangeCacheImpl changeCache) {
|
||||
this.repoManager = repoManager;
|
||||
this.dbProvider = dbProvider;
|
||||
this.tagCache = tagCache;
|
||||
|
@ -154,7 +154,7 @@ public class ProjectControl {
|
||||
private final PermissionCollection.Factory permissionFilter;
|
||||
private final Collection<ContributorAgreement> contributorAgreements;
|
||||
private final TagCache tagCache;
|
||||
private final SearchingChangeCacheImpl changeCache;
|
||||
@Nullable private final SearchingChangeCacheImpl changeCache;
|
||||
|
||||
private List<SectionMatcher> allSections;
|
||||
private List<SectionMatcher> localSections;
|
||||
@ -171,7 +171,7 @@ public class ProjectControl {
|
||||
ChangeNotes.Factory changeNotesFactory,
|
||||
ChangeControl.Factory changeControlFactory,
|
||||
TagCache tagCache,
|
||||
SearchingChangeCacheImpl changeCache,
|
||||
@Nullable SearchingChangeCacheImpl changeCache,
|
||||
@CanonicalWebUrl @Nullable String canonicalWebUrl,
|
||||
@Assisted CurrentUser who,
|
||||
@Assisted ProjectState ps) {
|
||||
|
@ -17,6 +17,7 @@ package com.google.gerrit.sshd.commands;
|
||||
import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE;
|
||||
import static org.eclipse.jgit.lib.RefDatabase.ALL;
|
||||
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@ -63,6 +64,7 @@ public class LsUserRefs extends SshCommand {
|
||||
private ChangeNotes.Factory changeNotesFactory;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
private SearchingChangeCacheImpl changeCache;
|
||||
|
||||
@Option(name = "--project", aliases = {"-p"}, metaVar = "PROJECT",
|
||||
|
@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.sshd.commands;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.git.SearchingChangeCacheImpl;
|
||||
@ -51,6 +52,7 @@ final class Upload extends AbstractGitCommand {
|
||||
private ChangeNotes.Factory changeNotesFactory;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
private SearchingChangeCacheImpl changeCache;
|
||||
|
||||
@Inject
|
||||
|
Loading…
Reference in New Issue
Block a user