This is an automated email from the ASF dual-hosted git repository.

tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git

commit 4f31bcec0200f80be4d1d10fba600a3c04923e89
Author: Thomas Vandahl <[email protected]>
AuthorDate: Sun Feb 8 17:44:46 2026 +0100

    Fix and document region configuration inheritance
---
 .../engine/control/CompositeCacheConfigurator.java | 16 ++++++---
 .../jcs4/access/SystemPropertyUnitTest.java        |  5 +--
 xdocs/RegionProperties.xml                         | 40 +++++++++++-----------
 xdocs/UpgradingFrom3x.xml                          |  7 ++++
 4 files changed, 39 insertions(+), 29 deletions(-)

diff --git 
a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfigurator.java
 
b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfigurator.java
index 53dfe111..079c3935 100644
--- 
a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfigurator.java
+++ 
b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/control/CompositeCacheConfigurator.java
@@ -250,15 +250,21 @@ public class CompositeCacheConfigurator
         Class<? extends ICompositeCacheAttributes> attributeClass = 
OptionConverter.findClassByKey(props, prefix);
         if (attributeClass == null)
         {
-            log.debug("Using default composite cache attributes class for 
region \"{0}\"", regName);
-            attributeClass = CompositeCacheAttributes.class;
+            if (defaultCCAttr != null)
+            {
+                attributeClass = defaultCCAttr.getClass();
+            }
+            else
+            {
+                attributeClass = CompositeCacheAttributes.class;
+            }
+            log.debug("Using default composite cache attributes class for 
region \"{0}\": {1}",
+                    regName, attributeClass.getName());
         }
 
         log.debug("Parsing options for \"{0}\"", prefix);
 
-        ICompositeCacheAttributes ccAttr = 
ConfigurationBuilder.create(attributeClass,
-                // FIXME: This is probably a bug, but SystemPropertyUnitTest 
relies on it.
-                /* defaultCCAttr */ CompositeCacheAttributes.defaults())
+        ICompositeCacheAttributes ccAttr = 
ConfigurationBuilder.create(attributeClass, defaultCCAttr)
                 .fromProperties(props, prefix)
                 .build()
                 .withCacheName( regName );
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/SystemPropertyUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/SystemPropertyUnitTest.java
index e7cf5d60..c2c4aa28 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/SystemPropertyUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/SystemPropertyUnitTest.java
@@ -22,7 +22,6 @@ package org.apache.commons.jcs4.access;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.apache.commons.jcs4.JCS;
-import org.apache.commons.jcs4.engine.control.CompositeCacheManager;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.MethodOrderer;
@@ -52,6 +51,7 @@ class SystemPropertyUnitTest
     @AfterEach
     void tearDown()
     {
+        JCS.shutdown();
         System.clearProperty( "MY_SYSTEM_PROPERTY_DISK_DIR" );
         System.clearProperty( "MY_SYSTEM_PROPERTY_MAX_SIZE" );
     }
@@ -87,9 +87,6 @@ class SystemPropertyUnitTest
     {
         System.setProperty( "MY_SYSTEM_PROPERTY_DISK_DIR", "system_set" );
 
-        final CompositeCacheManager mgr = 
CompositeCacheManager.getUnconfiguredInstance();
-        mgr.configure( "/TestSystemProperties.ccf" );
-
         final CacheAccess<String, String> cache = JCS.getInstance( "missing" );
         assertEquals( 100, cache.getCacheAttributes().maxObjects(),
                       "We should have used the default property for the memory 
size" );
diff --git a/xdocs/RegionProperties.xml b/xdocs/RegionProperties.xml
index dd9392ee..9f296a7f 100644
--- a/xdocs/RegionProperties.xml
+++ b/xdocs/RegionProperties.xml
@@ -28,13 +28,14 @@
                <section name="Cache Region Configuration">
 
                        <p>
-                               The following properties apply to any cache 
region. They
-                               can be specified as default values and 
specified on a
-                               region by region basis. There are three types of
-                               settings: auxiliary, cache, and element. The 
cache
-                               settings define the memory management for the 
region.
-                               The element settings define default element 
behavior
-                               within the region.
+                               The following properties apply to any cache 
region. They can be specified as 
+                default values and specified on a region by region basis. If a 
region is not 
+                explicitly defined in the cache configuration then it inherits 
the cache 
+                default settings. Every region specified in the cache 
configuration inherits 
+                the cache default settings, so only changed attributes need to 
be specified.
+                There are three types of settings: auxiliary, cache, and 
element. The cache
+                               settings define the memory management for the 
region. The element settings 
+                define default element behavior within the region.
                        </p>
 
                        <subsection name="Region (Auxiliary) Properties">
@@ -67,6 +68,14 @@
                                                <th>Required</th>
                                                <th>Default Value</th>
                                        </tr>
+                    <tr>
+                        <td></td>
+                        <td>
+                            The class that implements the Composite Cache 
Attributes record.
+                        </td>
+                        <td>N</td>
+                        
<td>org.apache.commons.jcs4.engine.CompositeCacheAttributes</td>
+                    </tr>
                                        <tr>
                                                <td>MaxObjects</td>
                                                <td>
@@ -76,8 +85,8 @@
                                                        cache. By default JCS 
uses the LRU memory
                                                        cache.
                                                </td>
-                                               <td>Y</td>
-                                               <td>n/a</td>
+                                               <td>N</td>
+                                               <td>100</td>
                                        </tr>
                                        <tr>
                                                <td>MemoryCacheName</td>
@@ -94,9 +103,7 @@
                                                        and an adaptive 
replacement algorithm.
                                                </td>
                                                <td>N</td>
-                                               <td>
-                                                       
org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache
-                                               </td>
+                                               
<td>org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache</td>
                                        </tr>
                                        <tr>
                                                <td>UseMemoryShrinker</td>
@@ -244,21 +251,14 @@ jcs.default.elementattributes.IsSpool=true
 jcs.default.elementattributes.IsRemote=true
 jcs.default.elementattributes.IsLateral=true
 
-# optional region "testCache1" specific configuration settings
+# optional region "testCache1" specific configuration settings (only those 
that differ from default)
 jcs.region.testCache1=
-jcs.region.testCache1.cacheattributes=org.apache.commons.jcs4.engine.CompositeCacheAttributes
 jcs.region.testCache1.cacheattributes.MaxObjects=123456
-jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache
-jcs.region.testCache1.cacheattributes.UseMemoryShrinker=true
 jcs.region.testCache1.cacheattributes.ShrinkerIntervalSeconds=30
 jcs.region.testCache1.cacheattributes.MaxMemoryIdleTimeSeconds=300
 jcs.region.testCache1.cacheattributes.MaxSpoolPerRun=100
 
jcs.region.testCache1.elementattributes=org.apache.commons.jcs4.engine.ElementAttributes
-jcs.region.testCache1.elementattributes.IsEternal=false
 jcs.region.testCache1.elementattributes.MaxLife=60000
-jcs.region.testCache1.elementattributes.IsSpool=true
-jcs.region.testCache1.elementattributes.IsLateral=true
-jcs.region.testCache1.elementattributes.IsRemote=true
         ]]>
                                </source>
                        </subsection>
diff --git a/xdocs/UpgradingFrom3x.xml b/xdocs/UpgradingFrom3x.xml
index 77c5bfaa..61fa52bd 100644
--- a/xdocs/UpgradingFrom3x.xml
+++ b/xdocs/UpgradingFrom3x.xml
@@ -121,6 +121,13 @@ 
jcs.default.cacheattributes=org.apache.commons.jcs4.engine.CompositeCacheAttribu
                </tr>
             </table>
          </p>
+         <p>
+           The documentation in the code always stated that region 
configurations inherit 
+           values from the default region settings. This, however, was never 
implemented.
+           Note that the behavior has been fixed in JCS 4.0.0. This may have 
implications
+           for your existing configurations. On the other hand, it makes the 
configuration
+           much shorter.
+         </p>
       </subsection>
     </section>
   </body>

Reply via email to