Skip to content

Commit

Permalink
Migrate to CLA Assistant; fix flaky test
Browse files Browse the repository at this point in the history
CLA Hub silently disappeared, along with the signatures it gathered.
Thankfully the Apache License covers all cases, such as contributions,
so this was not required. We offer a CLA in case if alleves concerns
by a corporate legal review. The same CLA terms apply: a direct copy
of Apache's with the names updated.

A test appears flaky on the CI due to weak/soft values being collected
during its execution. The test now better ensures that the entries are
not collected, hopefully stabilizing this test case.
  • Loading branch information
ben-manes committed Oct 11, 2020
1 parent 6280143 commit ef5c40e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
To get started, [sign the Contributor License Agreement](https://www.clahub.com/agreements/ben-manes/caffeine).
To get started, [sign the Contributor License Agreement](https://cla-assistant.io/ben-manes/caffeine).

Then head over to [How to Contribute](https://github.com/ben-manes/caffeine/wiki/Contribute)
for details on the build system.
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,19 @@ public void schedule_delay(Cache<Integer, Duration> cache, CacheContext context)
doAnswer(onRemoval).when(context.removalListener()).onRemoval(any(), any(), any());
when(context.scheduler().schedule(any(), task.capture(), delay.capture(), any()))
.thenReturn(Futures.immediateFuture(null));
Map<Integer, Duration> original = new HashMap<>();

Integer key1 = 1;
Duration value1 = Duration.ofNanos(context.ticker().read());
original.put(key1, value1);
cache.put(key1, value1);

Duration insertDelay = Duration.ofMillis(10);
context.ticker().advance(insertDelay);

Integer key2 = 2;
Duration value2 = Duration.ofNanos(context.ticker().read());
original.put(key2, value2);
cache.put(key2, value2);

Duration expireKey1 = Duration.ofNanos(1 + delay.getValue()).minus(insertDelay);
Expand All @@ -207,7 +210,7 @@ public void schedule_delay(Cache<Integer, Duration> cache, CacheContext context)

Duration maxExpirationPeriod = Duration.ofNanos(
context.expiryTime().timeNanos() + Pacer.TOLERANCE);
assertThat(actualExpirationPeriods, is(aMapWithSize(2)));
assertThat(actualExpirationPeriods, is(aMapWithSize(original.size())));
assertThat(actualExpirationPeriods.get(key1), is(lessThanOrEqualTo(maxExpirationPeriod)));
assertThat(actualExpirationPeriods.get(key2), is(lessThanOrEqualTo(maxExpirationPeriod)));
}
Expand Down

0 comments on commit ef5c40e

Please sign in to comment.