diff --git a/.github/workflows/lincheck.yml b/.github/workflows/lincheck.yml index e171097f2a..0d22cdf88d 100644 --- a/.github/workflows/lincheck.yml +++ b/.github/workflows/lincheck.yml @@ -20,6 +20,4 @@ jobs: java-version: ${{ env.JAVA_VERSION }} - uses: gradle/gradle-build-action@v2 - name: Run lincheck - run: | - set -eux - ./gradlew lincheckTest + run: ./gradlew lincheckTest diff --git a/build.gradle b/build.gradle index 59a82a76e2..0ed457b943 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,8 @@ import net.ltgt.gradle.errorprone.CheckSeverity apply plugin: 'io.github.gradle-nexus.publish-plugin' apply plugin: 'org.kordamp.gradle.source-stats' apply plugin: 'com.github.ben-manes.versions' -apply plugin: 'com.github.kt3k.coveralls' -apply plugin: 'jacoco' + +apply from: "${rootDir}/gradle/coveralls.gradle" buildscript { apply from: "${rootDir}/gradle/dependencies.gradle" @@ -19,12 +19,6 @@ buildscript { } } -tasks.register('testReport', TestReport) { - group = 'Build' - description = 'Generates an aggregate test report' - destinationDir = file("${buildDir}/reports/allTests") -} - allprojects { apply plugin: 'com.github.ethankhall.semantic-versioning' apply from: "${rootDir}/gradle/eclipse.gradle" @@ -55,9 +49,9 @@ subprojects { java.toolchain.languageVersion = JavaLanguageVersion.of(System.env.'JAVA_VERSION' ?: 11) - configurations { - all { - exclude group: 'org.hamcrest', module: 'hamcrest-core' + configurations.all { + resolutionStrategy.dependencySubstitution { + substitute module('org.hamcrest:hamcrest-core') using module(testLibraries.hamcrest) } } @@ -85,16 +79,6 @@ subprojects { } } - tasks.withType(Test).configureEach { - rootProject.testReport.reportOn it - it.dependsOn(jar) - - // ensure tasks don't overwrite the default report directories used by the 'test' task - reports.html.destination = file("${buildDir}/reports/${name}") - reports.junitXml.destination = file("${buildDir}/reports/${name}/results") - binaryResultsDirectory = file("${buildDir}/reports/${name}/results/binary/${name}") - } - if (project != project(':caffeine')) { javadoc.options.linksOffline( "https://static.javadoc.io/${group}/caffeine/${version}/", @@ -112,35 +96,3 @@ nexusPublishing { } } } - -// Only report code coverage for projects that are distributed -def coveredProjects = [ 'caffeine', 'guava', 'jcache' ].collect { project(it) } - -tasks.register('jacocoFullReport', JacocoReport) { - group = 'Coverage reports' - description = 'Generates an aggregate report from all subprojects' - - coveredProjects.each { - sourceSets it.sourceSets.main - mustRunAfter it.tasks.withType(Test) - executionData fileTree(it.buildDir.absolutePath).include('jacoco/*.exec') - } - - reports { - html.required = true // human readable - xml.required = true // required by coveralls - } -} - -coveralls { - sourceDirs = coveredProjects.sourceSets.main.allSource.srcDirs.flatten() - jacocoReportPath = "${buildDir}/reports/jacoco/jacocoFullReport/jacocoFullReport.xml" -} - -tasks.named('coveralls').configure { - group = 'Coverage reports' - description = 'Uploads the aggregated coverage report to Coveralls' - - dependsOn jacocoFullReport - onlyIf { System.env.'CI' } -} diff --git a/caffeine/build.gradle b/caffeine/build.gradle index 73221b8ac8..60c3ad4c47 100644 --- a/caffeine/build.gradle +++ b/caffeine/build.gradle @@ -59,7 +59,6 @@ dependencies { jmh libraries.flipTables jmh libraries.jackrabbit jmh libraries.expiringMap - jmh libraries.elasticSearch jmh libraries.concurrentlinkedhashmap javaPoetImplementation libraries.guava @@ -88,7 +87,6 @@ tasks.named('jar').configure { attributes 'Import-Package': '' attributes 'Export-Package': [ 'com.github.benmanes.caffeine', - 'com.github.benmanes.caffeine.base', 'com.github.benmanes.caffeine.cache', 'com.github.benmanes.caffeine.cache.stats'].join(',') attributes 'Automatic-Module-Name': 'com.github.benmanes.caffeine' diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/CacheType.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/CacheType.java index 5c5f37d585..f2e99a586c 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/CacheType.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/CacheType.java @@ -25,7 +25,6 @@ import com.github.benmanes.caffeine.cache.impl.ConcurrentHashMapV7; import com.github.benmanes.caffeine.cache.impl.ConcurrentMapCache; import com.github.benmanes.caffeine.cache.impl.Ehcache3; -import com.github.benmanes.caffeine.cache.impl.ElasticSearchCache; import com.github.benmanes.caffeine.cache.impl.ExpiringMapCache; import com.github.benmanes.caffeine.cache.impl.GuavaCache; import com.github.benmanes.caffeine.cache.impl.LinkedHashMapCache; @@ -89,11 +88,6 @@ public enum CacheType { return new Ehcache3<>(maximumSize); } }, - ElasticSearch { - @Override public BasicCache create(int maximumSize) { - return new ElasticSearchCache<>(maximumSize); - } - }, ExpiringMap_Fifo { @Override public BasicCache create(int maximumSize) { return new ExpiringMapCache<>(maximumSize, ExpirationPolicy.CREATED); diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/GetPutBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/GetPutBenchmark.java index b25730e8a5..6c8ce0517e 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/GetPutBenchmark.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/GetPutBenchmark.java @@ -51,7 +51,6 @@ public class GetPutBenchmark { "Caffeine", "ConcurrentLinkedHashMap", "Guava", - "ElasticSearch", "Jackrabbit", "Cache2k", "Ehcache3", diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/ElasticSearchCache.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/ElasticSearchCache.java deleted file mode 100644 index 9d4df3f13d..0000000000 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/ElasticSearchCache.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2016 Ben Manes. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.github.benmanes.caffeine.cache.impl; - -import org.elasticsearch.common.cache.Cache; -import org.elasticsearch.common.cache.CacheBuilder; - -import com.github.benmanes.caffeine.cache.BasicCache; - -/** - * @author ben.manes@gmail.com (Ben Manes) - */ -public final class ElasticSearchCache implements BasicCache { - private final Cache cache; - - public ElasticSearchCache(int maximumSize) { - cache = CacheBuilder.builder() - .setMaximumWeight(maximumSize) - .build(); - } - - @Override - public V get(K key) { - return cache.get(key); - } - - @Override - public void put(K key, V value) { - cache.put(key, value); - } - - @Override - public void remove(K key) { - cache.invalidate(key); - } - - @Override - public void clear() { - cache.invalidateAll(); - } -} diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java index f2b85d179d..681eeea576 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java @@ -473,7 +473,7 @@ public Expiry expiry() { return null; } - @Override + /** Returns the {@link Ticker} used by this cache for expiration. */ public Ticker expirationTicker() { return Ticker.disabledTicker(); } diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalCache.java index 042d379ceb..4b85fecbed 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalCache.java @@ -58,9 +58,6 @@ interface LocalCache extends ConcurrentMap { /** Returns the {@link Expiry} used by this cache. */ @Nullable Expiry expiry(); - /** Returns the {@link Ticker} used by this cache for expiration. */ - Ticker expirationTicker(); - /** Returns the {@link Ticker} used by this cache for statistics. */ Ticker statsTicker(); diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java index a235537a6c..a7e124f6cd 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java @@ -228,11 +228,6 @@ void discardRefresh(Object keyReference) { } } - @Override - public Ticker expirationTicker() { - return Ticker.disabledTicker(); - } - @Override public Ticker statsTicker() { return ticker; diff --git a/checksum.xml b/checksum.xml index b4e3c54933..3ce04d0b15 100644 --- a/checksum.xml +++ b/checksum.xml @@ -57,6 +57,7 @@ + @@ -145,6 +146,7 @@ + @@ -424,6 +426,9 @@ 51372BCAFB87FBFDEC5DAB387014693B86A800CE5954C847A11DA1E36FC5ACF95110F335B0BBA31B1E1D31960DE0F5565F34A73CA5567EBFDFEACC70DB574EFB + + 8D6E78F1F9D54E0D50525328BAD7CC904F98CAC05FF7B783784E2115185CBE0A4CF659B8A8129E0759D96775A1B2A0AFB63953ECA897FEDEFF8A2B7A371B804E + 2C09B102601DF179B615EF37F5E56B9AA1100BB2A17D742B8CB452C1A193C44ED3EBE029FEAFB9822D55A680D99B682184C733D56F835874DD01B02209AFA13D @@ -673,6 +678,9 @@ 6F44BE79691ECF80771220086E796626B45D053BEA913AD16E5AD3DEA3FA07995FEC8045DA6265B4FDF837EA985AD7E58DC398405D3FFA79C4E2DAA5881E2D09 + + 51F4EECF44441AC5BA056087C6C9BC10750FC5A2DBE3FBEE69372B2187E9B045C198C8BED86003657D77BB3297C41B32008CFC4857BA8E02DD461029A5D5C237 + 16D30BE564723B74F312B4E7D06F349370FB6726B3162778C869CD723ECA2A40C4972C2757B3E107E1820CEC0D70B0BD2B96EFCD466518FC64495F7AEF97967A diff --git a/gradle/coveralls.gradle b/gradle/coveralls.gradle new file mode 100644 index 0000000000..383e05046b --- /dev/null +++ b/gradle/coveralls.gradle @@ -0,0 +1,59 @@ +/** + * Configurations for code coverage + */ +apply plugin: 'com.github.kt3k.coveralls' +apply plugin: 'jacoco' + +def testReport = tasks.register('testReport', TestReport) { + group = 'Build' + description = 'Generates an aggregate test report' + destinationDir = file("${buildDir}/reports/allTests") +} + +subprojects { + apply plugin: 'java-library' + + tasks.withType(Test).configureEach { testTask -> + testReport.configure { + reportOn testTask + } + testTask.dependsOn(jar) + + // ensure tasks don't overwrite the default report directories used by the 'test' task + reports.html.destination = file("${buildDir}/reports/${name}") + reports.junitXml.destination = file("${buildDir}/reports/${name}/results") + binaryResultsDirectory = file("${buildDir}/reports/${name}/results/binary/${name}") + } +} + +// Only report code coverage for projects that are distributed +def coveredProjects = [ 'caffeine', 'guava', 'jcache' ].collect { project(it) } + +tasks.register('jacocoFullReport', JacocoReport) { + group = 'Coverage reports' + description = 'Generates an aggregate report from all subprojects' + + coveredProjects.each { + sourceSets it.sourceSets.main + mustRunAfter it.tasks.withType(Test) + executionData fileTree(it.buildDir.absolutePath).include('jacoco/*.exec') + } + + reports { + html.required = true // human readable + xml.required = true // required by coveralls + } +} + +coveralls { + sourceDirs = coveredProjects.sourceSets.main.allSource.srcDirs.flatten() + jacocoReportPath = "${buildDir}/reports/jacoco/jacocoFullReport/jacocoFullReport.xml" +} + +tasks.named('coveralls').configure { + group = 'Coverage reports' + description = 'Uploads the aggregated coverage report to Coveralls' + + dependsOn jacocoFullReport + onlyIf { System.env.'CI' } +} diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 635d38d0e3..7a7acc1d69 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -26,7 +26,7 @@ ext { versions = [ akka: '2.6.18', - cache2k: '2.5.1.Alpha', + cache2k: '2.5.3.Beta', checkerFramework: '3.21.1', coherence: '20.06', commonsCompress: '1.21', @@ -37,14 +37,13 @@ ext { config: '1.4.1', ehcache3: '3.10.0-alpha0', errorprone: '2.10.0', - elasticSearch: '8.0.0-beta1', expiringMap: '0.5.10', fastfilter: '1.0.2', fastutil: '8.5.6', flipTables: '1.1.0', googleJavaFormat: '1.13.0', guava: '31.0.1-jre', - jackrabbit: '1.40.0', + jackrabbit: '1.42.0', jamm: '0.3.3', javaObjectLayout: '0.16', javapoet: '1.13.0', @@ -53,27 +52,27 @@ ext { jmh: '1.34', joor: '0.9.14', jsr330: '1', - nullaway: '0.9.4', + nullaway: '0.9.5', ohc: '0.6.1', osgiComponentAnnotations: '1.5.0', picocli: '4.6.2', - slf4j: '2.0.0-alpha5', + slf4j: '2.0.0-alpha6', tcache: '2.0.1', stream: '2.9.8', univocityParsers: '2.9.1', ycsb: '0.17.0', xz: '1.9', - zstd: '1.5.1-1', + zstd: '1.5.2-1', ] testVersions = [ awaitility: '4.1.1', - guice: '5.0.1', + guice: '5.1.0', hamcrest: '2.2', jcacheTck: '1.1.1', jctools: '3.3.0', junit: '4.13.2', lincheck: '2.14.1', - mockito: '4.2.0', + mockito: '4.3.0', paxExam: '4.13.5', slf4jTest: '2.4.1', testng: '7.5', @@ -93,14 +92,14 @@ ext { jmh: '0.6.6', jmhReport: '0.9.0', nexusPublish: '1.1.0', - nullaway: '1.2.0', + nullaway: '1.3.0', pmd: '6.41.0', semanticVersioning: '1.1.0', shadow: '7.1.2', sonarqube: '3.3', spotbugs: '4.5.3', spotbugsContrib: '7.4.7', - spotbugsPlugin: '5.0.4', + spotbugsPlugin: '5.0.5', stats: '0.47.0', versions: '0.41.0', ] @@ -123,10 +122,6 @@ ext { ehcache3: "org.ehcache:ehcache:${versions.ehcache3}", errorproneAnnotations: "com.google.errorprone:error_prone_annotations:${versions.errorprone}", errorproneCore: "com.google.errorprone:error_prone_core:${versions.errorprone}", - elasticSearch: dependencies.create("org.elasticsearch:elasticsearch:${versions.elasticSearch}") { - exclude module: 'elasticsearch-plugin-classloader' - exclude group: 'org.apache.lucene' - }, expiringMap: "net.jodah:expiringmap:${versions.expiringMap}", fastfilter: "io.github.fastfilter:fastfilter:${versions.fastfilter}", fastutil: "it.unimi.dsi:fastutil-core:${versions.fastutil}", diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c731a88072..b40d46db28 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-rc-1-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/simulator/build.gradle b/simulator/build.gradle index d4314cd474..47342ad57e 100644 --- a/simulator/build.gradle +++ b/simulator/build.gradle @@ -27,7 +27,6 @@ dependencies { implementation libraries.expiringMap implementation libraries.commonsLang3 implementation libraries.commonsMath3 - implementation libraries.elasticSearch implementation libraries.commonsCompress implementation libraries.univocityParsers diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/Registry.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/Registry.java index d24fab160e..55dfab1593 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/Registry.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/Registry.java @@ -55,7 +55,6 @@ import com.github.benmanes.caffeine.cache.simulator.policy.product.Cache2kPolicy; import com.github.benmanes.caffeine.cache.simulator.policy.product.CaffeinePolicy; import com.github.benmanes.caffeine.cache.simulator.policy.product.Ehcache3Policy; -import com.github.benmanes.caffeine.cache.simulator.policy.product.ElasticSearchPolicy; import com.github.benmanes.caffeine.cache.simulator.policy.product.ExpiringMapPolicy; import com.github.benmanes.caffeine.cache.simulator.policy.product.GuavaPolicy; import com.github.benmanes.caffeine.cache.simulator.policy.product.OhcPolicy; @@ -233,7 +232,6 @@ private void registerProduct() { register(CaffeinePolicy.class, CaffeinePolicy::new); register(Ehcache3Policy.class, Ehcache3Policy::new); register(ExpiringMapPolicy.class, ExpiringMapPolicy::new); - register(ElasticSearchPolicy.class, ElasticSearchPolicy::new); } @AutoValue diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/ElasticSearchPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/ElasticSearchPolicy.java deleted file mode 100644 index 8238507566..0000000000 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/ElasticSearchPolicy.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2016 Ben Manes. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.github.benmanes.caffeine.cache.simulator.policy.product; - -import static com.github.benmanes.caffeine.cache.simulator.policy.Policy.Characteristic.WEIGHTED; -import static com.google.common.base.Preconditions.checkState; - -import java.util.Set; - -import org.elasticsearch.common.cache.Cache; -import org.elasticsearch.common.cache.Cache.CacheStats; -import org.elasticsearch.common.cache.CacheBuilder; - -import com.github.benmanes.caffeine.cache.simulator.BasicSettings; -import com.github.benmanes.caffeine.cache.simulator.policy.AccessEvent; -import com.github.benmanes.caffeine.cache.simulator.policy.Policy; -import com.github.benmanes.caffeine.cache.simulator.policy.Policy.PolicySpec; -import com.github.benmanes.caffeine.cache.simulator.policy.PolicyStats; -import com.typesafe.config.Config; - -/** - * ElasticSearch's LRU cache. - * - * @author ben.manes@gmail.com (Ben Manes) - */ -@PolicySpec(name = "product.ElasticSearch", characteristics = WEIGHTED) -public final class ElasticSearchPolicy implements Policy { - private final Cache cache; - private final PolicyStats policyStats; - - public ElasticSearchPolicy(Config config, Set characteristics) { - policyStats = new PolicyStats(name()); - BasicSettings settings = new BasicSettings(config); - CacheBuilder builder = CacheBuilder.builder() - .removalListener(notification -> policyStats.recordEviction()) - .setMaximumWeight(settings.maximumSize()); - if (characteristics.contains(WEIGHTED)) { - builder.weigher((key, value) -> value.weight()); - } - cache = builder.build(); - } - - @Override - public void record(AccessEvent event) { - AccessEvent value = cache.get(event.key()); - if (value == null) { - cache.put(event.key(), event); - policyStats.recordWeightedMiss(event.weight()); - } else { - policyStats.recordWeightedHit(event.weight()); - if (event.weight() != value.weight()) { - cache.put(event.key(), event); - } - } - } - - @Override - public PolicyStats stats() { - return policyStats; - } - - @Override - public void finished() { - CacheStats stats = cache.stats(); - checkState(policyStats.hitCount() == stats.getHits()); - checkState(policyStats.missCount() == stats.getMisses()); - } -} diff --git a/simulator/src/main/resources/reference.conf b/simulator/src/main/resources/reference.conf index 6bbc9f6188..68636621da 100644 --- a/simulator/src/main/resources/reference.conf +++ b/simulator/src/main/resources/reference.conf @@ -108,7 +108,6 @@ caffeine.simulator { product.Caffeine, product.Ehcache3, product.ExpiringMap, - product.ElasticSearch, ] # The admission policy (opposite of eviction policy)