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

@@ -15,6 +15,7 @@
package com.google.gerrit.server.permissions;
import static com.google.gerrit.server.permissions.DefaultPermissionMappings.globalPermissionName;
import static com.google.gerrit.server.project.ProjectCache.illegalState;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toSet;
@@ -103,7 +104,7 @@ public class DefaultPermissionBackend extends PermissionBackend {
@Override
public ForProject project(Project.NameKey project) {
try {
ProjectState state = projectCache.checkedGet(project);
ProjectState state = projectCache.get(project).orElseThrow(illegalState(project));
ProjectControl control =
PerThreadCache.getOrCompute(
PerThreadCache.Key.create(ProjectControl.class, project, user.getCacheKey()),