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 b5e315b8f51ad67cd825d7cdac94f783090d035b Author: Thomas Vandahl <[email protected]> AuthorDate: Thu Mar 19 18:28:38 2026 +0100 Change type of RemoteHttpCacheAttributes.socketTimeout and connectionTimeout to Duration --- .../remote/AbstractRemoteAuxiliaryCache.java | 4 +-- .../auxiliary/remote/RemoteCacheAttributes.java | 8 ++--- .../remote/http/client/AbstractHttpClient.java | 4 +-- .../http/client/RemoteHttpCacheAttributes.java | 34 ++++++++++++---------- .../TimeoutConfigurableRMISocketFactory.java | 12 ++++---- .../server/RemoteCacheServerFactoryUnitTest.java | 8 ++--- .../src/test/test-conf/TestRemoteClient.ccf | 2 +- src/site/xdoc/CacheEventLogging.xml | 2 +- src/site/xdoc/JDBCDiskCacheProperties.xml | 4 +-- src/site/xdoc/RemoteCacheProperties.xml | 16 ++++++++++ src/site/xdoc/RemoteHttpCacheProperties.xml | 8 ++--- src/site/xdoc/UpgradingFrom3x.xml | 25 ++++++++++++++++ src/site/xdoc/UsingJCSBasicWeb.xml | 3 -- 13 files changed, 85 insertions(+), 45 deletions(-) diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/AbstractRemoteAuxiliaryCache.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/AbstractRemoteAuxiliaryCache.java index 022f14be..ab8f013d 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/AbstractRemoteAuxiliaryCache.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/AbstractRemoteAuxiliaryCache.java @@ -95,7 +95,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V> } // use a pool if it is greater than 0 - log.debug( "GetTimeoutMillis() = {0}", + log.debug( "GetTimeout() = {0}", () -> getAuxiliaryCacheAttributes().getGetTimeout() ); if (!getAuxiliaryCacheAttributes().getGetTimeout().isNegative()) @@ -367,7 +367,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V> /** * Synchronously get from the remote cache; if failed, replace the remote handle with a zombie. * <p> - * Use threadpool to timeout if a value is set for GetTimeoutMillis + * Use threadpool to timeout if a value is set for GetTimeout * <p> * If we are a cluster client, we need to leave the Element in its serialized form. Cluster * clients cannot deserialize objects. Cluster clients get ICacheElementSerialized objects from diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheAttributes.java index 5f50edc9..5bbf1b52 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheAttributes.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheAttributes.java @@ -193,11 +193,11 @@ public class RemoteCacheAttributes } /** - * @param millis + * @param getTimeout */ - public void setGetTimeoutMillis( final int millis ) + public void setGetTimeout( final Duration getTimeout ) { - getTimeout = Duration.ofMillis(millis); + this.getTimeout = getTimeout; } /** @@ -247,7 +247,7 @@ public class RemoteCacheAttributes { final StringBuilder buf = new StringBuilder(super.toString()); buf.append( "\n receive = [" + isReceive() + "]" ); - buf.append( "\n getTimeoutMillis = [" + getGetTimeout() + "]" ); + buf.append( "\n getTimeout = [" + getGetTimeout() + "]" ); buf.append( "\n threadPoolName = [" + getThreadPoolName() + "]" ); buf.append( "\n localClusterConsistency = [" + isLocalClusterConsistency() + "]" ); buf.append( "\n zombieQueueMaxSize = [" + getZombieQueueMaxSize() + "]" ); diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/AbstractHttpClient.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/AbstractHttpClient.java index 3e244850..f326646d 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/AbstractHttpClient.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/AbstractHttpClient.java @@ -95,8 +95,8 @@ public abstract class AbstractHttpClient } builder.setDefaultRequestConfig(RequestConfig.custom() - .setConnectTimeout(getRemoteHttpCacheAttributes().getConnectionTimeoutMillis()) - .setSocketTimeout(getRemoteHttpCacheAttributes().getSocketTimeoutMillis()) + .setConnectTimeout((int)getRemoteHttpCacheAttributes().getConnectionTimeout().toMillis()) + .setSocketTimeout((int)getRemoteHttpCacheAttributes().getSocketTimeout().toMillis()) // By default we instruct HttpClient to ignore cookies. .setCookieSpec(CookieSpecs.IGNORE_COOKIES) .build()); diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheAttributes.java index aa7f90f6..87b4ef8f 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheAttributes.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/http/client/RemoteHttpCacheAttributes.java @@ -1,5 +1,7 @@ package org.apache.commons.jcs4.auxiliary.remote.http.client; +import java.time.Duration; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -38,10 +40,10 @@ public class RemoteHttpCacheAttributes private int maxConnectionsPerHost = 100; /** The socket timeout. */ - private int socketTimeoutMillis = 3000; + private Duration socketTimeout = Duration.ofSeconds(3); /** The socket connections timeout */ - private int connectionTimeoutMillis = 5000; + private Duration connectionTimeout = Duration.ofSeconds(5); /** HTTP version to use. */ private String httpVersion = DEFAULT_HTTP_VERSION; @@ -62,11 +64,11 @@ public class RemoteHttpCacheAttributes private String remoteHttpClientClassName = DEFAULT_REMOTE_HTTP_CLIENT_CLASS_NAME; /** - * @return the connectionTimeoutMillis + * @return the connectionTimeout */ - public int getConnectionTimeoutMillis() + public Duration getConnectionTimeout() { - return connectionTimeoutMillis; + return connectionTimeout; } /** @@ -94,11 +96,11 @@ public class RemoteHttpCacheAttributes } /** - * @return the socketTimeoutMillis + * @return the socketTimeout */ - public int getSocketTimeoutMillis() + public Duration getSocketTimeout() { - return socketTimeoutMillis; + return socketTimeout; } /** @@ -134,11 +136,11 @@ public class RemoteHttpCacheAttributes } /** - * @param connectionTimeoutMillis the connectionTimeoutMillis to set + * @param connectionTimeout the connectionTimeout to set */ - public void setConnectionTimeoutMillis( final int connectionTimeoutMillis ) + public void setConnectionTimeout( final Duration connectionTimeout ) { - this.connectionTimeoutMillis = connectionTimeoutMillis; + this.connectionTimeout = connectionTimeout; } /** @@ -190,11 +192,11 @@ public class RemoteHttpCacheAttributes } /** - * @param socketTimeoutMillis the socketTimeoutMillis to set + * @param socketTimeout the socketTimeout to set */ - public void setSocketTimeoutMillis( final int socketTimeoutMillis ) + public void setSocketTimeout( final Duration socketTimeout ) { - this.socketTimeoutMillis = socketTimeoutMillis; + this.socketTimeout = socketTimeout; } /** @@ -214,9 +216,9 @@ public class RemoteHttpCacheAttributes final StringBuilder buf = new StringBuilder(); buf.append( "\n RemoteHttpCacheAttributes" ); buf.append( "\n maxConnectionsPerHost = [" + getMaxConnectionsPerHost() + "]" ); - buf.append( "\n socketTimeoutMillis = [" + getSocketTimeoutMillis() + "]" ); + buf.append( "\n socketTimeout = [" + getSocketTimeout() + "]" ); buf.append( "\n httpVersion = [" + getHttpVersion() + "]" ); - buf.append( "\n connectionTimeoutMillis = [" + getConnectionTimeoutMillis() + "]" ); + buf.append( "\n connectionTimeout = [" + getConnectionTimeout() + "]" ); buf.append( "\n includeCacheNameAsParameter = [" + isIncludeCacheNameAsParameter() + "]" ); buf.append( "\n includeKeysAndPatternsAsParameter = [" + isIncludeKeysAndPatternsAsParameter() + "]" ); buf.append( "\n includeRequestTypeasAsParameter = [" + isIncludeRequestTypeasAsParameter() + "]" ); diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/server/TimeoutConfigurableRMISocketFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/server/TimeoutConfigurableRMISocketFactory.java index 10a28395..d911da25 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/server/TimeoutConfigurableRMISocketFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/remote/server/TimeoutConfigurableRMISocketFactory.java @@ -81,7 +81,7 @@ public class TimeoutConfigurableRMISocketFactory /** * @return the openTimeout */ - public Duration getOpenTimeoutDuration() + public Duration getOpenTimeout() { return openTimeout; } @@ -89,7 +89,7 @@ public class TimeoutConfigurableRMISocketFactory /** * @return the readTimeout */ - public Duration getReadTimeoutDuration() + public Duration getReadTimeout() { return readTimeout; } @@ -97,16 +97,16 @@ public class TimeoutConfigurableRMISocketFactory /** * @param openTimeout the openTimeout to set */ - public void setOpenTimeout( final int openTimeout ) + public void setOpenTimeout( final Duration openTimeout ) { - this.openTimeout = Duration.ofMillis(openTimeout); + this.openTimeout = openTimeout; } /** * @param readTimeout the readTimeout to set */ - public void setReadTimeout( final int readTimeout ) + public void setReadTimeout( final Duration readTimeout ) { - this.readTimeout = Duration.ofMillis(readTimeout); + this.readTimeout = readTimeout; } } 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 55f5a33c..f8e01f6f 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 @@ -57,8 +57,8 @@ class RemoteCacheServerFactoryUnitTest void testConfigureObjectSpecificCustomFactory_withProperty_TimeoutConfigurableRMIScoketFactory() { // SETUP - final long readTimeout = 1234; - final long openTimeout = 1234; + final Duration readTimeout = Duration.ofMillis(1234); + final Duration openTimeout = Duration.ofMillis(1234); final Properties props = new Properties(); props.put( IRemoteCacheConstants.CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX, TimeoutConfigurableRMISocketFactory.class.getName() ); props.put( IRemoteCacheConstants.CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX + ".readTimeout", String.valueOf( readTimeout ) ); @@ -70,9 +70,9 @@ class RemoteCacheServerFactoryUnitTest // VERIFY assertNotNull( result, "Should have a custom socket factory." ); assertInstanceOf(TimeoutConfigurableRMISocketFactory.class, result, "Should be a TimeoutConfigurableRMISocketFactory"); - assertEquals( readTimeout, ((TimeoutConfigurableRMISocketFactory) result).getReadTimeoutDuration().toMillis(), + assertEquals( readTimeout, ((TimeoutConfigurableRMISocketFactory) result).getReadTimeout(), "Wrong readTimeout" ); - assertEquals( openTimeout, ((TimeoutConfigurableRMISocketFactory) result).getOpenTimeoutDuration().toMillis(), + assertEquals( openTimeout, ((TimeoutConfigurableRMISocketFactory) result).getOpenTimeout(), "Wrong readTimeout" ); } diff --git a/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf b/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf index 54e0f78c..db86dd8b 100644 --- a/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestRemoteClient.ccf @@ -34,6 +34,6 @@ jcs.auxiliary.RC.attributes.RemoveUponRemotePut=false # jcs.auxiliary.RC.attributes.RemoteServiceName=RemoteCache # -1 means no timeout, this is the default # if the timeout is -1, no threadpool will be used. -jcs.auxiliary.RC.attributes.GetTimeoutMillis=-1 +jcs.auxiliary.RC.attributes.GetTimeout=PT-0.001s # jcs.auxiliary.RC.attributes.ThreadPoolName=remote_cache_client # jcs.auxiliary.RC.attributes.GetOnly=false diff --git a/src/site/xdoc/CacheEventLogging.xml b/src/site/xdoc/CacheEventLogging.xml index f0f55cea..c42d2ea7 100644 --- a/src/site/xdoc/CacheEventLogging.xml +++ b/src/site/xdoc/CacheEventLogging.xml @@ -45,7 +45,7 @@ jcs.auxiliary.RC.attributes.RemoveUponRemotePut=false # jcs.auxiliary.RC.attributes.RemoteServiceName=RemoteCache # -1 means no timeout, this is the default # if the timeout is -1, no threadpool will be used. -jcs.auxiliary.RC.attributes.GetTimeoutMillis=500 +jcs.auxiliary.RC.attributes.GetTimeout=PT0.5s jcs.auxiliary.RC.attributes.ThreadPoolName=remote_cache_client jcs.auxiliary.RC.attributes.GetOnly=false jcs.auxiliary.RC.cacheeventlogger=org.apache.commons.jcs4.engine.logging.CacheEventLoggerDebugLogger diff --git a/src/site/xdoc/JDBCDiskCacheProperties.xml b/src/site/xdoc/JDBCDiskCacheProperties.xml index 5cdc7554..7456f70b 100644 --- a/src/site/xdoc/JDBCDiskCacheProperties.xml +++ b/src/site/xdoc/JDBCDiskCacheProperties.xml @@ -121,9 +121,9 @@ </tr> <tr> <td>jndiTTL</td> - <td>The time between two JNDI lookups in ms.</td> + <td>The time between two JNDI lookups</td> <td>N</td> - <td>0</td> + <td>PT0s (no caching)</td> </tr> <tr> <td>tableName</td> diff --git a/src/site/xdoc/RemoteCacheProperties.xml b/src/site/xdoc/RemoteCacheProperties.xml index fc6ec957..1004ac4d 100644 --- a/src/site/xdoc/RemoteCacheProperties.xml +++ b/src/site/xdoc/RemoteCacheProperties.xml @@ -111,6 +111,22 @@ <td>N</td> <td>false</td> </tr> + <tr> + <td>GetTimeout</td> + <td> + Must be greater than 0 for a pool to be used. + </td> + <td>N</td> + <td>PT-0.001s</td> + </tr> + <tr> + <td>ThreadPoolName</td> + <td> + The name of the thread pool used for get operations. + </td> + <td>N</td> + <td>remote_cache_client</td> + </tr> <tr> <td>Receive</td> <td> diff --git a/src/site/xdoc/RemoteHttpCacheProperties.xml b/src/site/xdoc/RemoteHttpCacheProperties.xml index d27bbab4..9f392aac 100644 --- a/src/site/xdoc/RemoteHttpCacheProperties.xml +++ b/src/site/xdoc/RemoteHttpCacheProperties.xml @@ -42,16 +42,16 @@ <td>100</td> </tr> <tr> - <td>socketTimeoutMillis</td> + <td>socketTimeout</td> <td> Read timeout.</td> <td>N</td> - <td>3000</td> + <td>PT3s</td> </tr> <tr> - <td>connectionTimeoutMillis</td> + <td>connectionTimeout</td> <td> Connection timeout.</td> <td>N</td> - <td>5000</td> + <td>PT5s</td> </tr> <tr> <td>httpVersion</td> diff --git a/src/site/xdoc/UpgradingFrom3x.xml b/src/site/xdoc/UpgradingFrom3x.xml index 430cfc2f..faf091e1 100644 --- a/src/site/xdoc/UpgradingFrom3x.xml +++ b/src/site/xdoc/UpgradingFrom3x.xml @@ -177,6 +177,16 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n <td>RmiSocketFactoryTimeoutMillis</td> <td>RmiSocketFactoryTimeout</td> </tr> + <tr> + <td>Remote HTTP Cache configuration (RemoteHttpCacheAttributes)</td> + <td>SocketTimeoutMillis</td> + <td>SocketTimeout</td> + </tr> + <tr> + <td></td> + <td>ConnectionTimeoutMillis</td> + <td>ConnectionTimeout</td> + </tr> </table> </p> <p> @@ -242,6 +252,11 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n <td>ShrinkerInterval</td> <td>PT5m</td> </tr> + <tr> + <td></td> + <td>jndiTTL</td> + <td>PT0s</td> + </tr> <tr> <td>Lateral TCP Cache configuration (LateralTCPCacheAttributes)</td> <td>SocketTimeOut</td> @@ -257,6 +272,16 @@ java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %3$s [%4$-7s] %5$s %n <td>RmiSocketFactoryTimeout</td> <td>PT5s</td> </tr> + <tr> + <td>Remote HTTP Cache configuration (RemoteHttpCacheAttributes)</td> + <td>socketTimeout</td> + <td>PT3s</td> + </tr> + <tr> + <td></td> + <td>connectionTimeout</td> + <td>PT5s</td> + </tr> </table> </p> </subsection> diff --git a/src/site/xdoc/UsingJCSBasicWeb.xml b/src/site/xdoc/UsingJCSBasicWeb.xml index 2a8fa57e..76489365 100644 --- a/src/site/xdoc/UsingJCSBasicWeb.xml +++ b/src/site/xdoc/UsingJCSBasicWeb.xml @@ -425,6 +425,3 @@ jcs.auxiliary.RFailover.attributes.GetOnly=false </section> </body> </document> - - -
