jackrabbit-oak-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OAK-3089) LIRS cache: zero size cache causes IllegalArgumentException
Date Thu, 09 Jul 2015 11:59:05 GMT

    [ https://issues.apache.org/jira/browse/OAK-3089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14620383#comment-14620383
] 

Thomas Mueller commented on OAK-3089:
-------------------------------------

Patch:

{noformat}
Index: src/main/java/org/apache/jackrabbit/oak/cache/CacheLIRS.java
===================================================================
--- src/main/java/org/apache/jackrabbit/oak/cache/CacheLIRS.java	(revision 1690034)
+++ src/main/java/org/apache/jackrabbit/oak/cache/CacheLIRS.java	(working copy)
@@ -409,8 +409,8 @@
      * @param maxMemory the maximum size (1 or larger)
      */
     public void setMaxMemory(long maxMemory) {
-        if (maxMemory <= 0) {
-            throw new IllegalArgumentException("Max memory must be larger than 0");
+        if (maxMemory < 0) {
+            throw new IllegalArgumentException("Max memory must not be negative");
         }
         this.maxMemory = maxMemory;
         if (segments != null) {
Index: src/test/java/org/apache/jackrabbit/oak/cache/CacheTest.java
===================================================================
--- src/test/java/org/apache/jackrabbit/oak/cache/CacheTest.java	(revision 1690034)
+++ src/test/java/org/apache/jackrabbit/oak/cache/CacheTest.java	(working copy)
@@ -90,7 +90,7 @@
             // expected
         }
         try {
-            test.setMaxMemory(0);
+            test.setMaxMemory(-1);
             fail();
         } catch (IllegalArgumentException e) {
             // expected
@@ -629,6 +629,15 @@
     }
     
     @Test
+    public void testZeroSizeCache() {
+        CacheLIRS<Integer, String> cache = createCache(0, 100);
+        cache.put(1, "Hello", 100);
+        cache.put(2, "World", 100);
+        cache.put(3, "!", 100);
+        assertFalse(cache.containsKey(1));
+    }
+    
+    @Test
     public void testRefresh() throws ExecutionException {
         CacheLIRS<Integer, String> cache = new CacheLIRS.Builder().
                 maximumWeight(100).
{noformat}

> LIRS cache: zero size cache causes IllegalArgumentException
> -----------------------------------------------------------
>
>                 Key: OAK-3089
>                 URL: https://issues.apache.org/jira/browse/OAK-3089
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>            Priority: Minor
>             Fix For: 1.2.3, 1.3.3, 1.0.17
>
>
> The LIRS cache does not support a zero size cache currently. Such a configuration causes
an IllegalArgumentException.
> Instead, no exception should be thrown, and no or a minimum size cache should be used.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message