ExpiringMap compares nanosecond times as time <= now. Both sides are from direct reads of System.nanoTime(). Unfortunately this violates the contract of that method,
* The value returned represents nanoseconds since some fixed but
* arbitrary <i>origin</i> time (perhaps in the future, so values
* may be negative).
* ...
* <p>The values returned by this method become meaningful only when
* the difference between two such values, obtained within the same
* instance of a Java virtual machine, is computed.
* ...
* one should use {@code t1 - t0 < 0}, not {@code t1 < t0},
* because of the possibility of numerical overflow.
This behavior is not intuitive and causes these simple oversights. However, failing to abide by that directive can lead to incorrect conclusions.
ExpiringMap compares nanosecond times as
time <= now
. Both sides are from direct reads ofSystem.nanoTime()
. Unfortunately this violates the contract of that method,This behavior is not intuitive and causes these simple oversights. However, failing to abide by that directive can lead to incorrect conclusions.