Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Dec 10, 2023
1 parent 0eb86f6 commit f172a2c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public void advance(long clock) {
public void advance_overflow() {
when(cache.evictEntry(captor.capture(), any(), anyLong())).thenReturn(true);

var timerWheel = new TimerWheel<Long, Long>();
timerWheel.nanos = -TimeUnit.DAYS.toNanos(365) / 2;
timerWheel.schedule(new Timer(timerWheel.nanos + SPANS[0]));

Expand All @@ -150,7 +149,6 @@ public void advance_overflow() {

@Test(dataProvider = "clock")
public void advance_backwards(long clock) {
var timerWheel = new TimerWheel<Long, Long>();
timerWheel.nanos = clock;

for (int i = 0; i < 1_000; i++) {
Expand All @@ -164,6 +162,31 @@ public void advance_backwards(long clock) {
verifyNoInteractions(cache);
}

@Test(dataProvider = "clock")
public void advance_reschedule(long clock) {
when(cache.evictEntry(captor.capture(), any(), anyLong())).thenReturn(true);
timerWheel.nanos = clock;

var t15 = new Timer(clock + TimeUnit.SECONDS.toNanos(15));
var t80 = new Timer(clock + TimeUnit.SECONDS.toNanos(80));
timerWheel.schedule(t15);
timerWheel.schedule(t80);

// discard T15, T80 in wheel[1]
timerWheel.advance(cache, clock + TimeUnit.SECONDS.toNanos(45));
assertThat(captor.getAllValues()).containsExactly(t15);
assertThat(timerWheel).hasSize(1);

// verify not discarded, T80 in wheel[0]
timerWheel.advance(cache, clock + TimeUnit.SECONDS.toNanos(70));
assertThat(timerWheel).hasSize(1);

// verify discarded T80
timerWheel.advance(cache, clock + TimeUnit.SECONDS.toNanos(90));
assertThat(captor.getAllValues()).containsExactly(t15, t80);
assertThat(timerWheel).isEmpty();
}

@Test
public void advance_exception() {
doThrow(new IllegalArgumentException())
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
asm = "9.6"
auto-value = "1.10.4"
awaitility = "4.2.0"
bcel = "6.6.1"
bcel = "6.8.0"
bnd = "6.4.0"
bouncycastle = "1.70"
cache2k = "2.6.1.Final"
caffeine = "3.1.8"
checker-framework = "3.41.0"
checkstyle = "10.12.5"
checkstyle = "10.12.6"
coherence = "22.06.2"
commons-collections4 = "4.4"
commons-compress = "1.25.0"
Expand All @@ -19,7 +19,7 @@ commons-text = "1.11.0"
concurrentlinkedhashmap = "1.4.2"
config = "1.4.3"
coveralls = "2.12.2"
dependency-check = "9.0.3"
dependency-check = "9.0.4"
eclipse-collections = "12.0.0.M3"
ehcache3 = "3.10.8"
errorprone-core = "2.23.0"
Expand Down Expand Up @@ -82,7 +82,7 @@ snakeyaml = "2.2"
sonarqube = "4.4.1.3373"
spotbugs-contrib = "7.6.3"
spotbugs-core = "4.8.2"
spotbugs-plugin = "6.0.1"
spotbugs-plugin = "6.0.2"
stream = "2.9.8"
tcache = "2.0.1"
testng = "7.8.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {

val objectLayout: Configuration by configurations.creating
dependencies {
objectLayout(project)
objectLayout(libs.java.`object`.layout)
}

Expand All @@ -18,17 +19,17 @@ modes.forEach { (mode, details) ->
tasks.register<JavaExec>(mode) {
group = "Object Layout"
description = details
classpath(objectLayout)
dependsOn(tasks.compileJava)
mainClass = "org.openjdk.jol.Main"
incompatibleWithConfigurationCache()
classpath(objectLayout, sourceSets.main.map { it.runtimeClasspath })

doFirst {
var className = findProperty("className") as String?
if (className == null) {
throw GradleException(
"Usage: $name -PclassName=com.github.benmanes.caffeine.cache.[CLASS_NAME]")
} else if (!className.startsWith("com")) {
} else if (!className.startsWith("com") && !className.startsWith("java")) {
className = "com.github.benmanes.caffeine.cache.$className"
}
args(name, className)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ plugins {

val checkstyleConfig: Configuration by configurations.creating

configurations.checkstyle.configure {
resolutionStrategy.dependencySubstitution {
substitute(module("com.google.collections:google-collections"))
.using(module(libs.guava.asProvider().get().toString()))
}
}

dependencies {
checkstyleConfig(libs.checkstyle) {
isTransitive = false
Expand Down

0 comments on commit f172a2c

Please sign in to comment.