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 654c8a4b42a57c2ff164d2b05286cafa9adc5261 Author: Thomas Vandahl <[email protected]> AuthorDate: Thu Mar 19 17:35:51 2026 +0100 Change type of RemoteCacheAttributes.rmiSocketFactoryTimeout to Duration --- .../auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java | 4 ++-- .../jcs4/auxiliary/disk/jdbc/ShrinkerThread.java | 6 +++--- .../auxiliary/remote/CommonRemoteCacheAttributes.java | 9 ++++++--- .../remote/behavior/ICommonRemoteCacheAttributes.java | 3 --- .../disk/jdbc/JDBCDataSourceFactoryUnitTest.java | 3 ++- .../remote/server/RemoteCacheServerFactoryUnitTest.java | 17 +++++++++-------- .../src/test/test-conf/TestRemoteCacheClientServer.ccf | 2 +- src/site/xdoc/RemoteCacheProperties.xml | 6 +++--- src/site/xdoc/UpgradingFrom3x.xml | 10 ++++++++++ 9 files changed, 36 insertions(+), 24 deletions(-) diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java index 3ce0f445..6c2ede34 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java @@ -214,9 +214,9 @@ public class JDBCDiskCacheAttributes /** * @param jndiTTL the jndiTTL to set */ - public void setJndiTTL(final long jndiTTL) + public void setJndiTTL(final Duration jndiTTL) { - this.jndiTTL = Duration.ofMillis(jndiTTL); + this.jndiTTL = jndiTTL; } /** diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/ShrinkerThread.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/ShrinkerThread.java index c2c52452..90aad8a4 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/ShrinkerThread.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/ShrinkerThread.java @@ -138,10 +138,10 @@ public class ShrinkerThread * How long should we wait between calls to deleteExpired when we are iterating through the list * of regions. * - * @param pauseBetweenRegionCallsMillis The pauseBetweenRegionCallsMillis to set. + * @param pauseBetweenRegionCalls The pauseBetweenRegionCalls to set. */ - public void setPauseBetweenRegionCallsMillis( final long pauseBetweenRegionCallsMillis ) + public void setPauseBetweenRegionCallsMillis(final Duration pauseBetweenRegionCalls ) { - this.pauseBetweenRegionCalls = Duration.ofMillis(pauseBetweenRegionCallsMillis); + this.pauseBetweenRegionCalls = pauseBetweenRegionCalls; } } diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/CommonRemoteCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/CommonRemoteCacheAttributes.java index 773172a9..72c081ed 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/CommonRemoteCacheAttributes.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/CommonRemoteCacheAttributes.java @@ -59,6 +59,9 @@ public abstract class CommonRemoteCacheAttributes /** Should we put and get from the clusters. */ private boolean localClusterConsistency; + /** The default timeout for the custom RMI socket factory */ + public static final Duration DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT = Duration.ofSeconds(10); + /** Read and connect timeout */ private Duration rmiSocketFactoryTimeout = DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT; @@ -250,11 +253,11 @@ public abstract class CommonRemoteCacheAttributes } /** - * @param rmiSocketFactoryTimeoutMillis The rmiSocketFactoryTimeoutMillis to set. + * @param rmiSocketFactoryTimeout The rmiSocketFactoryTimeout to set. */ - public void setRmiSocketFactoryTimeoutMillis( final int rmiSocketFactoryTimeoutMillis ) + public void setRmiSocketFactoryTimeout(final Duration rmiSocketFactoryTimeout) { - this.rmiSocketFactoryTimeout = Duration.ofMillis(rmiSocketFactoryTimeoutMillis); + this.rmiSocketFactoryTimeout = rmiSocketFactoryTimeout; } /** diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/behavior/ICommonRemoteCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/behavior/ICommonRemoteCacheAttributes.java index db698ab7..59e74ef0 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/behavior/ICommonRemoteCacheAttributes.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/behavior/ICommonRemoteCacheAttributes.java @@ -31,9 +31,6 @@ import org.apache.commons.jcs4.auxiliary.remote.server.behavior.RemoteType; public interface ICommonRemoteCacheAttributes extends AuxiliaryCacheAttributes { - /** The default timeout for the custom RMI socket factory */ - Duration DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT = Duration.ofMillis(10000); - /** * Gets the clusterServers attribute of the IRemoteCacheAttributes object * diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java index ddd51ffe..6fafd1aa 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java @@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import java.sql.SQLException; +import java.time.Duration; import java.util.HashMap; import java.util.Hashtable; import java.util.Map; @@ -149,7 +150,7 @@ class JDBCDataSourceFactoryUnitTest { // SETUP final String jndiPath = "java:comp/env/jdbc/MyDB"; - final long ttl = 300000L; + final Duration ttl = Duration.ofDays(4); System.setProperty(Context.INITIAL_CONTEXT_FACTORY, MockInitialContextFactory.class.getName()); diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java index e30f6ff4..55f5a33c 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java @@ -24,9 +24,10 @@ import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import java.rmi.server.RMISocketFactory; +import java.time.Duration; import java.util.Properties; -import org.apache.commons.jcs4.auxiliary.remote.behavior.ICommonRemoteCacheAttributes; +import org.apache.commons.jcs4.auxiliary.remote.CommonRemoteCacheAttributes; import org.apache.commons.jcs4.auxiliary.remote.behavior.IRemoteCacheConstants; import org.junit.jupiter.api.Test; @@ -140,21 +141,21 @@ class RemoteCacheServerFactoryUnitTest "Wrong registryKeepAliveDelayMillis" ); } - /** Verify that we get the registryKeepAliveDelayMillis value */ + /** Verify that we get the rmiSocketFactoryTimeout value */ @Test - void testConfigureRemoteCacheServerAttributes_rmiSocketFactoryTimeoutMillisPresent() + void testConfigureRemoteCacheServerAttributes_rmiSocketFactoryTimeoutPresent() { // SETUP - final int rmiSocketFactoryTimeoutMillis = 123245; + final Duration rmiSocketFactoryTimeout = Duration.ofMillis(123245); final Properties props = new Properties(); - props.put( IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".rmiSocketFactoryTimeoutMillis", String.valueOf( rmiSocketFactoryTimeoutMillis ) ); + props.put(IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".rmiSocketFactoryTimeout", String.valueOf(rmiSocketFactoryTimeout)); // DO WORK final RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY - assertEquals( rmiSocketFactoryTimeoutMillis, result.getRmiSocketFactoryTimeout().toMillis(), - "Wrong rmiSocketFactoryTimeoutMillis" ); + assertEquals( rmiSocketFactoryTimeout, result.getRmiSocketFactoryTimeout(), + "Wrong rmiSocketFactoryTimeout" ); } /** Verify that we get the timeout value */ @@ -168,7 +169,7 @@ class RemoteCacheServerFactoryUnitTest final RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY - assertEquals( ICommonRemoteCacheAttributes.DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT, + assertEquals( CommonRemoteCacheAttributes.DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT, result.getRmiSocketFactoryTimeout(), "Wrong timeout" ); } diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteCacheClientServer.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteCacheClientServer.ccf index 52e0428d..6dd32423 100644 --- a/commons-jcs4-core/src/test/test-conf/TestRemoteCacheClientServer.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestRemoteCacheClientServer.ccf @@ -22,7 +22,7 @@ registry.port=11020 # client callback port. jcs.remotecache.serverattributes.servicePort=13010 -jcs.remotecache.serverattributes.RmiSocketFactoryTimeoutMillis=12345 +jcs.remotecache.serverattributes.RmiSocketFactoryTimeout=PT12.345s # cluster setting jcs.remotecache.serverattributes.LocalClusterConsistency=true diff --git a/src/site/xdoc/RemoteCacheProperties.xml b/src/site/xdoc/RemoteCacheProperties.xml index a495b632..fc6ec957 100644 --- a/src/site/xdoc/RemoteCacheProperties.xml +++ b/src/site/xdoc/RemoteCacheProperties.xml @@ -90,7 +90,7 @@ <td>true</td> </tr> <tr> - <td>RmiSocketFactoryTimeoutMillis</td> + <td>RmiSocketFactoryTimeout</td> <td> If this is greater than 0, then a custom socket factory will be installed in the VM. @@ -98,7 +98,7 @@ communication. </td> <td>N</td> - <td>5000</td> + <td>PT5s</td> </tr> <tr> <td>GetOnly</td> @@ -154,7 +154,7 @@ jcs.auxiliary.RC=org.apache.commons.jcs4.auxiliary.remote.RemoteCacheFactory jcs.auxiliary.RC.attributes.FailoverServers=localhost:1101,localhost:1102 jcs.auxiliary.RC.attributes.LocalPort=1201 jcs.auxiliary.RC.attributes.RemoveUponRemotePut=false -jcs.auxiliary.RC.attributes.RmiSocketFactoryTimeoutMillis=5000 +jcs.auxiliary.RC.attributes.RmiSocketFactoryTimeout=PT5s jcs.auxiliary.RC.attributes.GetOnly=false jcs.auxiliary.RC.attributes.Receive=false ]]> diff --git a/src/site/xdoc/UpgradingFrom3x.xml b/src/site/xdoc/UpgradingFrom3x.xml index a286f48d..430cfc2f 100644 --- a/src/site/xdoc/UpgradingFrom3x.xml +++ b/src/site/xdoc/UpgradingFrom3x.xml @@ -172,6 +172,11 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n <td>ShrinkerIntervalSeconds</td> <td>ShrinkerInterval</td> </tr> + <tr> + <td>Remote Cache configuration (RemoteCacheAttributes)</td> + <td>RmiSocketFactoryTimeoutMillis</td> + <td>RmiSocketFactoryTimeout</td> + </tr> </table> </p> <p> @@ -247,6 +252,11 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n <td>OpenTimeOut</td> <td>PT2s</td> </tr> + <tr> + <td>Remote Cache configuration (RemoteCacheAttributes)</td> + <td>RmiSocketFactoryTimeout</td> + <td>PT5s</td> + </tr> </table> </p> </subsection>
