1 Reply Latest reply on Feb 10, 2009 5:17 PM by Alex Fu

    Removing non-existing key causes losing of other entry

    Alex Fu Newbie

      Here is a very small standalone program compiled and executed using 3.0.2. What it does are:
      (0) create and start a Cache with no customization at all;
      (1) put a key/value pair in a Node;
      (2) remove a non-existing key from the same Node;
      (3) try to retrieve the value stored in step (1). It's null.

      If I have more than 1 entry before calling remove() then everything is fine.

      Also played with some eviction settings with big minTimeToLive value but still got the same result.

      It's very suspicious... Seems like a serious bug.

      import org.jboss.cache.Cache;
      import org.jboss.cache.DefaultCacheFactory;

      public class TestCache
      public static void main(String[] argv)
      Cache cc = new DefaultCacheFactory().createCache();

      cc.put("/test", "key1", "value1");
      System.out.println("Size of cache " + cc.getKeys("/test").size());
      Object r = cc.remove("/test", "key2");
      System.out.println("What is removed " + r);
      System.out.println("Size of cache " + cc.getKeys("/test").size());
      Object o = cc.get("/test", "key1");
      System.out.println("O is " + o);


      Size of cache 1
      What is removed null
      Size of cache 0
      O is null