diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 3425e4361c..1a4ecd446c 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -19,15 +19,8 @@ jobs: - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v2 with: + cache: 'gradle' distribution: 'zulu' java-version: ${{ matrix.java }} - - name: Cache Gradle packages - uses: actions/cache@v2.1.7 - with: - path: | - ~/.gradle/wrapper - ~/.gradle/caches - key: ${{ runner.os }}-${{ github.job }}-${{ matrix.java }}-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle - name: Run analyzers run: ./.github/scripts/analyze.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7eeb8caa7f..aa96ad1e48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,16 +21,9 @@ jobs: - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v2 with: + cache: 'gradle' distribution: 'zulu' java-version: ${{ matrix.java }} - - name: Cache Gradle packages - uses: actions/cache@v2.1.7 - with: - path: | - ~/.gradle/wrapper - ~/.gradle/caches - key: ${{ runner.os }}-${{ github.job }}-${{ matrix.java }}-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle - name: Run tests run: ./.github/scripts/test.sh - name: Publish Coverage diff --git a/.github/workflows/lincheck.yml b/.github/workflows/lincheck.yml index d50364d8de..d5fb8bfb41 100644 --- a/.github/workflows/lincheck.yml +++ b/.github/workflows/lincheck.yml @@ -15,16 +15,9 @@ jobs: - name: Set up JDK ${{ env.JAVA_VERSION }} uses: actions/setup-java@v2 with: + cache: 'gradle' distribution: 'zulu' java-version: ${{ env.JAVA_VERSION }} - - name: Cache Gradle packages - uses: actions/cache@v2.1.7 - with: - path: | - ~/.gradle/wrapper - ~/.gradle/caches - key: ${{ runner.os }}-${{ github.job }}-${{ matrix.java }}-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle - name: Run lincheck run: | set -eux diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml index a620c372e5..a5403499fe 100644 --- a/.github/workflows/qodana.yml +++ b/.github/workflows/qodana.yml @@ -17,14 +17,6 @@ jobs: with: distribution: 'zulu' java-version: ${{ env.JAVA_VERSION }} - - name: Cache Gradle packages - uses: actions/cache@v2.1.7 - with: - path: | - ~/.gradle/wrapper - ~/.gradle/caches - key: ${{ runner.os }}-${{ github.job }}-${{ env.JAVA_VERSION }}-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle - name: Build run: ./gradlew build -x test - name: Cache Qodana dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c40da070c..c009d58964 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,16 +11,9 @@ jobs: - name: Set up JDK 11 uses: actions/setup-java@v2 with: - distribution: 'zulu' + cache: 'gradle' java-version: 11 - - name: Cache Gradle packages - uses: actions/cache@v2.1.7 - with: - path: | - ~/.gradle/wrapper - ~/.gradle/caches - key: ${{ runner.os }}-${{ github.job }}-${{ matrix.java }}-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle + distribution: 'zulu' - name: Releasing env: NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CacheTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CacheTest.java index baade25eba..d452ba0494 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CacheTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CacheTest.java @@ -47,6 +47,7 @@ import com.github.benmanes.caffeine.cache.testing.CacheValidationListener; import com.github.benmanes.caffeine.cache.testing.CheckNoStats; import com.github.benmanes.caffeine.testing.Int; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.primitives.Ints; @@ -360,6 +361,20 @@ public void getAll_present_full(Cache cache, CacheContext context) { assertThat(context).stats().hits(result.size()).misses(0).success(0).failures(0); } + @CacheSpec(removalListener = { Listener.DEFAULT, Listener.REJECTING }) + @Test(dataProvider = "caches") + public void getAll_exceeds(Cache cache, CacheContext context) { + var result = cache.getAll(Set.of(context.absentKey()), keys -> context.absent()); + + var expected = new ImmutableMap.Builder() + .putAll(context.original()) + .putAll(context.absent()) + .build(); + assertThat(cache).containsExactlyEntriesIn(expected); + assertThat(context).stats().hits(0).misses(result.size()).success(1).failures(0); + assertThat(result).containsExactlyEntriesIn(Map.of(context.absentKey(), context.absentValue())); + } + @Test(dataProvider = "caches") @CacheSpec(population = { Population.SINGLETON, Population.PARTIAL, Population.FULL }, removalListener = { Listener.DEFAULT, Listener.REJECTING }) diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LoadingCacheTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LoadingCacheTest.java index 734cf5530c..76060bd90a 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LoadingCacheTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LoadingCacheTest.java @@ -23,6 +23,7 @@ import static com.github.benmanes.caffeine.cache.testing.CacheContextSubject.assertThat; import static com.github.benmanes.caffeine.cache.testing.CacheSubject.assertThat; import static com.github.benmanes.caffeine.testing.Awaits.await; +import static com.github.benmanes.caffeine.testing.CollectionSubject.assertThat; import static com.github.benmanes.caffeine.testing.FutureSubject.assertThat; import static com.github.benmanes.caffeine.testing.IntSubject.assertThat; import static com.github.benmanes.caffeine.testing.MapSubject.assertThat; @@ -221,6 +222,17 @@ public void getAll_present_full(LoadingCache cache, CacheContext conte assertThat(context).stats().hits(result.size()).misses(0).success(0).failures(0); } + @Test(dataProvider = "caches") + @CacheSpec(loader = { Loader.BULK_NEGATIVE_EXCEEDS }, + removalListener = { Listener.DEFAULT, Listener.REJECTING }) + public void getAll_exceeds(LoadingCache cache, CacheContext context) { + var result = cache.getAll(context.absentKeys()); + + assertThat(result.keySet()).containsExactlyElementsIn(context.absentKeys()); + assertThat(cache).hasSizeGreaterThan(context.initialSize() + context.absentKeys().size()); + assertThat(context).stats().hits(0).misses(result.size()).success(1).failures(0); + } + @Test(dataProvider = "caches") @CacheSpec(loader = { Loader.NEGATIVE, Loader.BULK_NEGATIVE }, population = { Population.SINGLETON, Population.PARTIAL, Population.FULL }, diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContext.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContext.java index 11d78e6f27..2463e8384e 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContext.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContext.java @@ -255,6 +255,7 @@ public Map absent() { return absent; } absent = new LinkedHashMap<>(); + absent.put(absentKey(), absentValue()); do { Int key = nextAbsentKey(); absent.put(key, key.negate());