diff --git a/.travis.yml b/.travis.yml index 2694000cc2..40493ed6f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,42 +1,37 @@ language: java -sudo: false + +dist: trusty +group: edge + +jdk: + - oraclejdk8 + - oraclejdk9 before_install: - - if [[ "x$JDK" == *'x9'* ]]; then remove_dir_from_path $JAVA_HOME/bin; export JAVA_HOME=/usr/lib/jvm/java-9-oracle; export PATH=$JAVA_HOME/bin:$PATH; java -Xmx32m -version; fi - cp gradle.properties.ci gradle.properties + - export JAVA_OPTS="-Xmx384m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -noverify" install: - ./gradlew assemble --stacktrace +before_script: + - export MAVEN_SKIP_RC=true script: - - JAVA_OPTS="-Xmx384m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -noverify" ./gradlew check + - ./gradlew check - sh -c 'cd examples/write-behind-rxjava && mvn test' after_success: - ./gradlew coveralls uploadArchives matrix: - fast_finish: true - include: - - jdk: oraclejdk8 # this will be overwritten by before_install above - addons: - apt: - packages: - - oracle-java9-installer - env: - JDK=9 - TERM=dumb -# Temporary disable JDK8 -# - jdk: oraclejdk8 -# env: -# TERM=dumb - -# https://docs.travis-ci.com/user/languages/java/#Projects-Using-Gradle + allow_failures: + - jdk: oraclejdk9 before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ cache: directories: + - $HOME/.m2 - $HOME/.gradle/caches/ - $HOME/.gradle/wrapper/ diff --git a/README.md b/README.md index 496d754047..865efe6574 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ Use Caffeine in a community provided integration: * [ScalaCache][scala-cache]: Simple caching in Scala * [Scaffeine][scaffeine]: Scala wrapper for Caffeine * [Ratpack][ratpack]: Lean & powerful HTTP apps + * [Finagle][finagle]: Extensible RPC system + * [Druid][druid]: Real-time Analytics ### In the News @@ -62,7 +64,6 @@ On the radar, * Early discussions with [HBase][hbase], [Cassandra][cassandra], [Solr][solr], and [ElasticSearch][elastic-search] * Postgres is [evaluating][postgres] whether to port the cache * Go [implementation][go-tinylfu] of the W-TinyLfu policy - * [Druid][druid] has a caffeine powered extension ### Download @@ -116,4 +117,5 @@ Snapshots of the development version are available in [postgres]: https://www.mail-archive.com/pgsql-hackers@postgresql.org/msg274326.html [go-tinylfu]: https://github.com/dgryski/go-tinylfu [ratpack]: https://github.com/ratpack/ratpack -[druid]: https://github.com/druid-io/druid/pull/3028 +[finagle]: https://github.com/twitter/finagle +[druid]: https://github.com/druid-io/druid diff --git a/build.gradle b/build.gradle index 611ddbe3c4..257dffeda7 100644 --- a/build.gradle +++ b/build.gradle @@ -25,6 +25,7 @@ allprojects { apply from: "${rootDir}/gradle/eclipse.gradle" repositories { + maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } maven { url 'https://jitpack.io' } mavenCentral() jcenter() @@ -34,10 +35,6 @@ allprojects { subprojects { apply plugin: 'com.github.ethankhall.semantic-versioning' apply plugin: 'nebula.provided-base' - if (!JavaVersion.current().isJava9Compatible()) { - // TODO: figure out which errorprone version supports JDK 9+ - apply plugin: 'net.ltgt.errorprone' - } apply plugin: 'java' apply plugin: 'osgi' @@ -46,6 +43,12 @@ subprojects { apply from: "${rootDir}/gradle/dependencies.gradle" apply from: "${rootDir}/gradle/object_layout.gradle" + if (JavaVersion.current().isJava9Compatible()) { + tasks.uploadArchives.enabled = false + } else { + apply plugin: 'net.ltgt.errorprone' + } + sourceCompatibility = JavaVersion.VERSION_1_8 group = 'com.github.ben-manes.caffeine' @@ -137,5 +140,5 @@ tasks.coveralls { description = 'Uploads the aggregated coverage report to Coveralls' dependsOn jacocoRootReport - onlyIf { System.env.'CI' } + onlyIf { System.env.'CI' && !JavaVersion.current().isJava9Compatible() } } diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/SynchronizedBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/SynchronizedBenchmark.java deleted file mode 100644 index de3234da28..0000000000 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/SynchronizedBenchmark.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2014 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; - -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Group; -import org.openjdk.jmh.annotations.GroupThreads; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.Threads; - -import com.github.benmanes.caffeine.base.UnsafeAccess; - -/** - * @author ben.manes@gmail.com (Ben Manes) - */ -@State(Scope.Benchmark) -public class SynchronizedBenchmark { - final Lock nrlock = new NonReentrantLock(); - final Lock rlock = new ReentrantLock(); - final Object olock = new Object(); - int counter; - - /* ---------------- synchronized -------------- */ - - @Benchmark @Threads(1) - public void synchronized_noContention() { - synchronized (olock) { - counter++; - } - } - - @Benchmark @Threads(4) - public int synchronized_contention() { - synchronized (olock) { - return counter++; - } - } - - /* ---------------- monitor byte code -------------- */ - - @Benchmark @Threads(1) - public int monitor_noContention() { - UnsafeAccess.UNSAFE.monitorEnter(olock); - try { - return counter++; - } finally { - UnsafeAccess.UNSAFE.monitorExit(olock); - } - } - - @Benchmark @Threads(4) - public int monitor_contention() { - UnsafeAccess.UNSAFE.monitorEnter(olock); - try { - return counter++; - } finally { - UnsafeAccess.UNSAFE.monitorExit(olock); - } - } - - /* ---------------- mixed -------------- */ - - @Benchmark @Group("mixed") @GroupThreads(1) - public int mixed_monitor() { - UnsafeAccess.UNSAFE.monitorEnter(olock); - try { - return counter++; - } finally { - UnsafeAccess.UNSAFE.monitorExit(olock); - } - } - - @Benchmark @Group("mixed") @GroupThreads(3) - public int mixed_sync() { - synchronized (olock) { - return counter++; - } - } - - /* ---------------- ReentrantLock -------------- */ - - @Benchmark @Threads(1) - public int reentrantLock_noContention() { - rlock.lock(); - try { - return counter++; - } finally { - rlock.unlock(); - } - } - - @Benchmark @Threads(4) - public int reentrantLock_contention() { - rlock.lock(); - try { - return counter++; - } finally { - rlock.unlock(); - } - } - - /* ---------------- NonReentrantLock -------------- */ - - @Benchmark @Threads(1) - public int nonReentrantLock_noContention() { - nrlock.lock(); - try { - return counter++; - } finally { - nrlock.unlock(); - } - } - - @Benchmark @Threads(4) - public int nonReentrantLock_contention() { - nrlock.lock(); - try { - return counter++; - } finally { - nrlock.unlock(); - } - } -} diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheGenerator.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheGenerator.java index b2715e6fcc..4f9b8b7d19 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheGenerator.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheGenerator.java @@ -15,6 +15,8 @@ */ package com.github.benmanes.caffeine.cache.testing; +import static com.google.common.base.Predicates.equalTo; +import static com.google.common.base.Predicates.not; import static org.mockito.Mockito.reset; import java.util.Arrays; @@ -86,6 +88,10 @@ private Set> combinations() { Set implementations = filterTypes( options.implementation(), cacheSpec.implementation()); + if (System.getProperty("java.version").contains("9")) { + values = Sets.filter(values, not(equalTo(ReferenceType.SOFT))); + } + if (isAsyncLoadingOnly) { values = values.contains(ReferenceType.STRONG) ? ImmutableSet.of(ReferenceType.STRONG) diff --git a/caffeine/testing.gradle b/caffeine/testing.gradle index c98954fbcf..fe796b8aa7 100644 --- a/caffeine/testing.gradle +++ b/caffeine/testing.gradle @@ -57,6 +57,8 @@ task isolatedTests(type: Test, group: 'Cache tests') { } task osgiTests(type: Test, group: 'Cache tests', description: 'Isolated OSGi tests') { + enabled = !JavaVersion.current().isJava9Compatible() + useJUnit() tasks.test.dependsOn(it) systemProperty 'caffeine.osgi.jar', project(':caffeine').jar.archivePath.path diff --git a/gradle/code_quality.gradle b/gradle/code_quality.gradle index 5118b53173..d32e0001d8 100644 --- a/gradle/code_quality.gradle +++ b/gradle/code_quality.gradle @@ -43,6 +43,10 @@ pmd { ruleSetConfig = resources.text.fromFile(file("${rootDir}/config/pmd/rulesSets.xml")) } +jacoco { + toolVersion = '0.7.8-SNAPSHOT' +} + jacocoTestReport { group = 'Coverage reports' description = 'Generates a test coverage report for a project' diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index a89923cc0a..e99a6df4cf 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -47,7 +47,7 @@ ext { jcache_tck: '1.0.1', jctools: '1.2.1', junit: '4.12', - mockito: '2.0.100-beta', + mockito: '2.0.106-beta', pax_exam: '4.9.1', testng: '6.9.12', truth: '0.24', @@ -64,7 +64,7 @@ ext { java_object_layout: '0.5', koloboke: '0.6.8', slf4j: '1.7.21', - tcache: '0.9.4', + tcache: '0.9.5', ] plugin_versions = [ checkstyle: '7.1', diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index be7efe5430..80723ef816 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-rc-2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip diff --git a/guava/build.gradle b/guava/build.gradle index 63a183c1d9..488f62bee3 100644 --- a/guava/build.gradle +++ b/guava/build.gradle @@ -28,6 +28,23 @@ tasks.withType(Javadoc) { } test { + useJUnit { + excludeCategories 'com.github.benmanes.caffeine.guava.OSGiTests' + } +} + +task osgiTests(type: Test, group: 'Cache tests', description: 'Isolated OSGi tests') { + enabled = !JavaVersion.current().isJava9Compatible() + tasks.test.dependsOn(it) + + useJUnit { + includeCategories 'com.github.benmanes.caffeine.guava.OSGiTests' + } +} + +tasks.withType(Test) { + enabled = !JavaVersion.current().isJava9Compatible() + systemProperty 'guava.osgi.version', versions.guava systemProperty 'caffeine.osgi.jar', project(':caffeine').jar.archivePath.path systemProperty 'caffeine-guava.osgi.jar', project(':guava').jar.archivePath.path diff --git a/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTest.java b/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTest.java index f33ebf7798..f41b77d2cf 100644 --- a/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTest.java +++ b/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTest.java @@ -22,6 +22,8 @@ import static org.ops4j.pax.exam.CoreOptions.options; import org.junit.Test; +import org.junit.experimental.categories.Categories.IncludeCategory; +import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.Option; @@ -37,6 +39,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @RunWith(PaxExam.class) +@IncludeCategory(OSGiTests.class) @ExamReactorStrategy(PerMethod.class) public final class OSGiTest { @@ -50,6 +53,7 @@ public Option[] config() { } @Test + @Category(OSGiTests.class) public void sanity() { CacheLoader loader = new CacheLoader() { @Override public Integer load(Integer key) { diff --git a/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTests.java b/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTests.java new file mode 100644 index 0000000000..faca91d0b0 --- /dev/null +++ b/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTests.java @@ -0,0 +1,21 @@ +/* + * 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.guava; + +/** + * @author ben.manes@gmail.com (Ben Manes) + */ +public interface OSGiTests {} diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/JCacheMBeanServerBuilder.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/JCacheMBeanServerBuilder.java index 52ed2ebca8..0a49c44164 100644 --- a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/JCacheMBeanServerBuilder.java +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/JCacheMBeanServerBuilder.java @@ -26,8 +26,6 @@ import javax.management.NotificationFilter; import javax.management.NotificationListener; -import com.sun.jmx.mbeanserver.JmxMBeanServer; - /** * An MBeanServer for the TCK that sets the mbean server id to the value of the * org.jsr107.tck.management.agentId system property. @@ -40,7 +38,7 @@ public final class JCacheMBeanServerBuilder extends MBeanServerBuilder { public MBeanServer newMBeanServer(String defaultDomain, MBeanServer outer, MBeanServerDelegate delegate) { MBeanServerDelegate jcacheDelegate = new JCacheMBeanServerDelegate(delegate); - return JmxMBeanServer.newMBeanServer(defaultDomain, outer, jcacheDelegate, false); + return new MBeanServerBuilder().newMBeanServer(defaultDomain, outer, jcacheDelegate); } private static final class JCacheMBeanServerDelegate extends MBeanServerDelegate { diff --git a/simulator/build.gradle b/simulator/build.gradle index 012053d88d..f71dc585a4 100644 --- a/simulator/build.gradle +++ b/simulator/build.gradle @@ -32,10 +32,8 @@ test { tasks.withType(Javadoc) { options.addStringOption('Xdoclint:none', '-quiet') - if (!JavaVersion.current().isJava9Compatible()) { - // https://github.com/akka/akka/issues/21165 - enabled = false - } + // https://github.com/akka/akka/issues/21165 + enabled = !JavaVersion.current().isJava9Compatible() } run {