Stop passing ReviewDb, etc. to ChangeData methods
Many methods that are intended for lazy initialization take a ReviewDb, and some take other helper objects such as GitRepositoryManager. This achieves the intended lazy-loading behavior but requires a lot of injection of dependencies into callers, and may become untenable as lazy loading of ChangeData requires more helpers. Instead, since after all this is Java, construct ChangeData with a Factory. This is subtle because it is used from a lot of places that need control over which ReviewDb handle to pass in, so the factory methods still need to take a db. ChangeData objects are still intended (i.e. safe) for use only by one thread, so having a single ReviewDb instance stored for the lifetime of the ChangeData should be fine. We just need to be careful about which we pass in, particularly in a place like ChangeIndexer. As a side effect, clean up some other injection, particularly in the predicate class hierarchy. Change-Id: I52e1eb2a76788c12dd95767e89095ab80df7e1cc
This commit is contained in:
@@ -103,7 +103,7 @@ public class DeleteReviewer implements RestModifyView<ReviewerResource, Input> {
|
||||
} finally {
|
||||
db.rollback();
|
||||
}
|
||||
indexer.index(rsrc.getChange());
|
||||
indexer.index(db, rsrc.getChange());
|
||||
return Response.none();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user