summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Philbert <alexandre.philbert@ericsson.com>2016-04-28 14:47:55 -0400
committerAlexandre Philbert <alexandre.philbert@ericsson.com>2016-04-29 13:46:53 -0400
commit3d35012d512a8d54382848379b798027f9b0ceda (patch)
tree84491e44f41fbe0866d28631f0eaa576ba4c4b86
parente2f4c2f127861c3f93861c527d2e9da8cb036a69 (diff)
Fix "Failed to reindex changes"
Since ReindexAfterUpdate starts tasks asynchronously, it is possible for a change that was once in the list of changes to get reindexed to no longer exist. This could happen if a draft change existed at the moment GetChanges was called and got deleted before db.get(id) is called. In this case, it returns null and ChangeDataFactory tries to create a ChangeData with a null Change which causes a ProvisionException. This fix simply checks if the returned value is null and doesn't try to reindex the change since it doesn't exist anymore. Change-Id: I15dc1bde132a826a7ce1c7afef9242a7537ab894
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/index/ReindexAfterUpdate.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/index/ReindexAfterUpdate.java b/gerrit-server/src/main/java/com/google/gerrit/server/index/ReindexAfterUpdate.java
index 45b7c4da31..8ec82c3e5f 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/index/ReindexAfterUpdate.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/index/ReindexAfterUpdate.java
@@ -141,7 +141,10 @@ public class ReindexAfterUpdate implements GitReferenceUpdatedListener {
// Reload change, as some time may have passed since GetChanges.
ReviewDb db = ctx.getReviewDbProvider().get();
Change c = db.changes().get(id);
- indexerFactory.create(executor, indexes).index(db, c);
+ // The change might have been a draft and got deleted
+ if (c != null) {
+ indexerFactory.create(executor, indexes).index(db, c);
+ }
return null;
}