
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
Windows
|
|
Issue Links:
|
Duplicate
|
|
This issue duplicates:
|
|
CACHE-260
NullPointerException in AbstractConcu...
|
|
|
|
|
|
|
|
The below test case illustrates the problem. Basically, it appears that when the LRU cache is replacing an item, it cannot clean up the groups, if the item was added using "no group", ie. cache.putInCache("key", "value") rather than cache.putInCache("key", "value", myGroup);
It's really puzzling that test 2 doesn't fail, as all that's changed is that cache.setCapacity(1) does not get called explicity. The last test passes because we use an empty String[] as group, but I'm not convinced if this is a valid work around.
import java.util.Properties;
import junit.framework.TestCase;
import com.opensymphony.oscache.base.AbstractCacheAdministrator;
import com.opensymphony.oscache.general.GeneralCacheAdministrator;
public class OSCacheOverflowTest extends TestCase {
/**
* This test fails on OSCache 2.3.2 when explicity using setCapacity
*/
public void testOverflowExplicitCapacity() {
Properties properties = new Properties();
properties.setProperty(AbstractCacheAdministrator.CACHE_ALGORITHM_KEY,"com.opensymphony.oscache.base.algorithm.LRUCache");
properties.setProperty(AbstractCacheAdministrator.CACHE_BLOCKING_KEY,"false");
properties.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY,"1");
properties.setProperty(AbstractCacheAdministrator.CACHE_MEMORY_KEY,"true");
properties.setProperty(AbstractCacheAdministrator.CACHE_PERSISTENCE_OVERFLOW_KEY, "true");
properties.setProperty(AbstractCacheAdministrator.CACHE_DISK_UNLIMITED_KEY,"false");
GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
cache.setCacheCapacity(1);
final String key1 = "key1";
final String key2 = "key2";
cache.putInCache(key1, "value1");
cache.putInCache(key2, "value2");
}
/**
* This test passes on OSCache 2.3.2
*/
public void testOverflowWithoutExplicitCapacity() {
Properties properties = new Properties();
properties.setProperty(AbstractCacheAdministrator.CACHE_ALGORITHM_KEY,"com.opensymphony.oscache.base.algorithm.LRUCache");
properties.setProperty(AbstractCacheAdministrator.CACHE_BLOCKING_KEY,"false");
properties.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY,"1");
properties.setProperty(AbstractCacheAdministrator.CACHE_MEMORY_KEY,"true");
properties.setProperty(AbstractCacheAdministrator.CACHE_PERSISTENCE_OVERFLOW_KEY, "true");
properties.setProperty(AbstractCacheAdministrator.CACHE_DISK_UNLIMITED_KEY,"false");
GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
final String key1 = "key1";
final String key2 = "key2";
cache.putInCache(key1, "value1");
cache.putInCache(key2, "value2");
}
/**
* This test passes on OSCache 2.3.2 when explicity setting empty group arrays
*/
public void testOverflowEmptyGroups() {
Properties properties = new Properties();
properties.setProperty(AbstractCacheAdministrator.CACHE_ALGORITHM_KEY,"com.opensymphony.oscache.base.algorithm.LRUCache");
properties.setProperty(AbstractCacheAdministrator.CACHE_BLOCKING_KEY,"false");
properties.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY,"1");
properties.setProperty(AbstractCacheAdministrator.CACHE_MEMORY_KEY,"true");
properties.setProperty(AbstractCacheAdministrator.CACHE_PERSISTENCE_OVERFLOW_KEY, "true");
properties.setProperty(AbstractCacheAdministrator.CACHE_DISK_UNLIMITED_KEY,"false");
GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
cache.setCacheCapacity(1);
final String key1 = "key1";
final String key2 = "key2";
cache.putInCache(key1, "value1", new String[] {});
cache.putInCache(key2, "value2", new String[] {});
}
}
The error trace:
Testcase: testOverflowExplicitCapacity(OSCacheOverflowTest): Caused an ERROR
null
java.lang.NullPointerException
at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.addGroupMappings(AbstractConcurrentReadCache.java:1508)
at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.remove(AbstractConcurrentReadCache.java:1790)
at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.put(AbstractConcurrentReadCache.java:1598)
at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.put(AbstractConcurrentReadCache.java:863)
at com.opensymphony.oscache.base.Cache.putInCache(Cache.java:624)
at com.opensymphony.oscache.base.Cache.putInCache(Cache.java:589)
at com.opensymphony.oscache.general.GeneralCacheAdministrator.putInCache(GeneralCacheAdministrator.java:249)
at com.opensymphony.oscache.general.GeneralCacheAdministrator.putInCache(GeneralCacheAdministrator.java:259)
at OSCacheOverflowTest.testOverflowExplicitCapacity(OSCacheOverflowTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
|
|
Description
|
The below test case illustrates the problem. Basically, it appears that when the LRU cache is replacing an item, it cannot clean up the groups, if the item was added using "no group", ie. cache.putInCache("key", "value") rather than cache.putInCache("key", "value", myGroup);
It's really puzzling that test 2 doesn't fail, as all that's changed is that cache.setCapacity(1) does not get called explicity. The last test passes because we use an empty String[] as group, but I'm not convinced if this is a valid work around.
import java.util.Properties;
import junit.framework.TestCase;
import com.opensymphony.oscache.base.AbstractCacheAdministrator;
import com.opensymphony.oscache.general.GeneralCacheAdministrator;
public class OSCacheOverflowTest extends TestCase {
/**
* This test fails on OSCache 2.3.2 when explicity using setCapacity
*/
public void testOverflowExplicitCapacity() {
Properties properties = new Properties();
properties.setProperty(AbstractCacheAdministrator.CACHE_ALGORITHM_KEY,"com.opensymphony.oscache.base.algorithm.LRUCache");
properties.setProperty(AbstractCacheAdministrator.CACHE_BLOCKING_KEY,"false");
properties.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY,"1");
properties.setProperty(AbstractCacheAdministrator.CACHE_MEMORY_KEY,"true");
properties.setProperty(AbstractCacheAdministrator.CACHE_PERSISTENCE_OVERFLOW_KEY, "true");
properties.setProperty(AbstractCacheAdministrator.CACHE_DISK_UNLIMITED_KEY,"false");
GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
cache.setCacheCapacity(1);
final String key1 = "key1";
final String key2 = "key2";
cache.putInCache(key1, "value1");
cache.putInCache(key2, "value2");
}
/**
* This test passes on OSCache 2.3.2
*/
public void testOverflowWithoutExplicitCapacity() {
Properties properties = new Properties();
properties.setProperty(AbstractCacheAdministrator.CACHE_ALGORITHM_KEY,"com.opensymphony.oscache.base.algorithm.LRUCache");
properties.setProperty(AbstractCacheAdministrator.CACHE_BLOCKING_KEY,"false");
properties.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY,"1");
properties.setProperty(AbstractCacheAdministrator.CACHE_MEMORY_KEY,"true");
properties.setProperty(AbstractCacheAdministrator.CACHE_PERSISTENCE_OVERFLOW_KEY, "true");
properties.setProperty(AbstractCacheAdministrator.CACHE_DISK_UNLIMITED_KEY,"false");
GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
final String key1 = "key1";
final String key2 = "key2";
cache.putInCache(key1, "value1");
cache.putInCache(key2, "value2");
}
/**
* This test passes on OSCache 2.3.2 when explicity setting empty group arrays
*/
public void testOverflowEmptyGroups() {
Properties properties = new Properties();
properties.setProperty(AbstractCacheAdministrator.CACHE_ALGORITHM_KEY,"com.opensymphony.oscache.base.algorithm.LRUCache");
properties.setProperty(AbstractCacheAdministrator.CACHE_BLOCKING_KEY,"false");
properties.setProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY,"1");
properties.setProperty(AbstractCacheAdministrator.CACHE_MEMORY_KEY,"true");
properties.setProperty(AbstractCacheAdministrator.CACHE_PERSISTENCE_OVERFLOW_KEY, "true");
properties.setProperty(AbstractCacheAdministrator.CACHE_DISK_UNLIMITED_KEY,"false");
GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
cache.setCacheCapacity(1);
final String key1 = "key1";
final String key2 = "key2";
cache.putInCache(key1, "value1", new String[] {});
cache.putInCache(key2, "value2", new String[] {});
}
}
The error trace:
Testcase: testOverflowExplicitCapacity(OSCacheOverflowTest): Caused an ERROR
null
java.lang.NullPointerException
at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.addGroupMappings(AbstractConcurrentReadCache.java:1508)
at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.remove(AbstractConcurrentReadCache.java:1790)
at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.put(AbstractConcurrentReadCache.java:1598)
at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.put(AbstractConcurrentReadCache.java:863)
at com.opensymphony.oscache.base.Cache.putInCache(Cache.java:624)
at com.opensymphony.oscache.base.Cache.putInCache(Cache.java:589)
at com.opensymphony.oscache.general.GeneralCacheAdministrator.putInCache(GeneralCacheAdministrator.java:249)
at com.opensymphony.oscache.general.GeneralCacheAdministrator.putInCache(GeneralCacheAdministrator.java:259)
at OSCacheOverflowTest.testOverflowExplicitCapacity(OSCacheOverflowTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
|
Show » |
|
CACHE-260a duplicate of this issue.