Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  Switch PatchListCache to using legacy cache backend
  Replace guava caches with caffeine

Add caffeine and caffeine-guava to Documentation/licenses.txt
which did not exist on earlier branches.

Change-Id: I40fb2798a8b6eda2e92e4409c1e57042a8e59ef4
This commit is contained in:
David Pursehouse
2019-12-04 17:43:38 +09:00
14 changed files with 243 additions and 32 deletions

View File

@@ -39,7 +39,9 @@ import com.google.gerrit.server.patch.PatchListKey;
import com.google.gerrit.server.patch.Text;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
@@ -65,6 +67,25 @@ public class PatchListCacheIT extends AbstractDaemonTest {
@Named("diff")
private Cache<PatchListKey, PatchList> abstractPatchListCache;
@Test
public void ensureLegacyBackendIsUsedForFileCacheBackend() throws Exception {
Field fileCacheField = patchListCache.getClass().getDeclaredField("fileCache");
fileCacheField.setAccessible(true);
// Use the reflection to access "localCache" field that is only present in Guava backend.
assertThat(
Arrays.stream(fileCacheField.get(patchListCache).getClass().getDeclaredFields())
.anyMatch(f -> f.getName().equals("localCache")))
.isTrue();
// intraCache (and all other cache backends) should use Caffeine backend.
Field intraCacheField = patchListCache.getClass().getDeclaredField("intraCache");
intraCacheField.setAccessible(true);
assertThat(
Arrays.stream(intraCacheField.get(patchListCache).getClass().getDeclaredFields())
.noneMatch(f -> f.getName().equals("localCache")))
.isTrue();
}
@Test
public void listPatchesAgainstBase() throws Exception {
commitBuilder().add(FILE_D, "4").message(SUBJECT_1).create();