Remove ProjectCache#checkedGet and move callers to #get

In an effort to make it impossible to use the ProjectCache interface the
wrong way, we are simplifying the interface to just a single option for
getting a project. The #get method throws a StorageException in case loading
failed and returns Optional#empty in case the project does not exist.

Change-Id: I7e3ecf2de3bc975d1c35ee8a848ac61def7af252
This commit is contained in:
Patrick Hiesel
2020-03-06 15:11:28 +01:00
parent 3a0ad58890
commit a6a44c5ab5
69 changed files with 344 additions and 256 deletions

View File

@@ -21,6 +21,7 @@ import static com.google.gerrit.server.change.ReviewerAdder.newAddReviewerInputF
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromFooters;
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromReviewers;
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
import static com.google.gerrit.server.project.ProjectCache.illegalState;
import static org.eclipse.jgit.lib.Constants.R_HEADS;
import com.google.common.base.Strings;
@@ -549,7 +550,11 @@ public class ReplaceOp implements BatchUpdateOp {
* show a transition from an oldValue of 0 to the new value.
*/
List<LabelType> labels =
projectCache.checkedGet(ctx.getProject()).getLabelTypes(notes).getLabelTypes();
projectCache
.get(ctx.getProject())
.orElseThrow(illegalState(ctx.getProject()))
.getLabelTypes(notes)
.getLabelTypes();
Map<String, Short> allApprovals = new HashMap<>();
Map<String, Short> oldApprovals = new HashMap<>();
for (LabelType lt : labels) {