cache2k / cache2k

Lightweight, high performance Java caching
http://cache2k.org
Apache License 2.0
705 stars 74 forks source link

Documentation Error: Expiry.toSharpTime(long) doesn't throw exception #207

Open yigithanbalci opened 7 months ago

yigithanbalci commented 7 months ago

In the JavaDoc of org.cache2k.expiry.Expiry.toSharpTime(long millis) method says the method throws IllegalArgumentException - if the time value is negative. However, in the code, it returns the already negative value as negative and does not throw an exception. From line 35 to 51 as follows:

/**
   * Convert the time value to a time representing a sharp expiry.
   * This essentially negates the time value and is provided for a more speaking coding style.
   *
   * @param millis expiry time since the milliseconds since epoch or {@link #ETERNAL} if no
   *               expiry is requested.
   * @throws IllegalArgumentException if the time value is negative
   */
  public static long toSharpTime(long millis) {
    if (millis == ETERNAL) {
      return ETERNAL;
    }
    if (millis < 0) {
      return millis;
    }
    return -millis;
  }
cruftex commented 7 months ago

Good catch, thanks! I will correct it.