Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-1979

org.jgroups.blocks.Cache.get() method always evicts values because it does not check Value.insertion_time

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Done
    • 3.6.1, 3.6.6
    • 3.6.7
    • None
    • Hide

      See CacheTest.java:

      • instantiate a Cache object
      • put an entry that does not expire for 60 seconds
      • immediately call Cache.get() using the entry key just added
      • observe that the returned value is null and the entry has been removed from the cache
      Show
      See CacheTest.java: instantiate a Cache object put an entry that does not expire for 60 seconds immediately call Cache.get() using the entry key just added observe that the returned value is null and the entry has been removed from the cache

    Description

      org.jgroups.blocks.Cache.get(String key) always evicts the matching entry and returns a value of null. It is doing this because the method is comparing the Value timeout property against the current system time without using the Value's insertion_time (unlike the evict() method, which does).

      I have created a simple unit test to illustrate this and provided a fix (from the 3.6.1.Final code base, which doesn't include the diamond operator updates). I added a couple of helper methods isExpired(Value val) and getValue(Value val)

      Attachments

        1. CacheTest.java
          0.6 kB
        2. CacheTest.java
          11 kB
        3. Cache.java
          10 kB
        4. Cache.java
          10 kB

        Activity

          People

            rhn-engineering-bban Bela Ban
            bjc_world Ben Johnson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: