GuavaBloomFilter implements ExpirableBloomFilter { @Override public boolean expired() { if (validPeriodAfterAccess == null) { return timer.utcNow().isAfter(expiration); } else { synchronized (this) { return timer.utcNow().isAfter(expiration); } } } @JsonCreator  GuavaBloomFilter(@JsonProperty("expectedInsertions") int expectedInsertions,
                     @JsonProperty("fpp") double fpp,
                     @JsonProperty("created") ZonedDateTime created,
                     @JsonProperty("expiration") ZonedDateTime expiration,
                     @Nullable @JsonProperty("validPeriodAfterAccess") Duration validPeriodAfterAccess);   GuavaBloomFilter(int expectedInsertions,
                     double fpp,
                     ZonedDateTime created,
                     ZonedDateTime expiration,
                     @Nullable Duration validPeriodAfterAccess,
                     Timer timer); private  GuavaBloomFilter(int expectedInsertions,
                             double fpp,
                             ZonedDateTime created,
                             ZonedDateTime expiration,
                             @Nullable Duration validPeriodAfterAccess,
                             com.google.common.hash.BloomFilter<CharSequence> filter,
                             Timer timer); @JsonSerialize(using = ZonedDateTimeSerializer.class) @JsonDeserialize(using = ZonedDateTimeDeserializer.class) ZonedDateTime created(); @Override @JsonSerialize(using = ZonedDateTimeSerializer.class) @JsonDeserialize(using = ZonedDateTimeDeserializer.class) synchronized ZonedDateTime expiration(); @Override @JsonGetter("fpp") double fpp(); @Override @JsonGetter("expectedInsertions") int expectedInsertions(); @Override boolean set(String value); @Override boolean expired(); @Override boolean mightContain(String value); void writeTo(OutputStream out); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testExpiredFilter() { final AdjustableTimer timer = new AdjustableTimer(); final ZonedDateTime creation = ZonedDateTime.now(ZoneOffset.UTC); final ZonedDateTime expiration = creation.plusSeconds(10); final GuavaBloomFilter filter = new GuavaBloomFilter( 1000, 0.001, creation, expiration, null, timer); timer.setNow(expiration); assertThat(filter.expired()).isFalse(); timer.setNow(expiration.plusSeconds(1)); assertThat(filter.expired()).isTrue(); }