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 91b0dbcba2f3cf9aa24ca5d35f7098ac547163aa Author: Thomas Vandahl <[email protected]> AuthorDate: Thu Feb 12 17:39:04 2026 +0100 Cleaner interface --- .../lateral/socket/tcp/LateralTCPCacheFactory.java | 9 ++------- .../jcs4/utils/discovery/UDPDiscoveryAttributes.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java index 0fa53263..8a15bdee 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java @@ -251,8 +251,6 @@ public class LateralTCPCacheFactory final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer ) { - UDPDiscoveryService discovery = null; - // create the UDP discovery for the TCP lateral if ( lac.isUdpDiscoveryEnabled() ) { @@ -263,12 +261,9 @@ public class LateralTCPCacheFactory // need a factory for this so it doesn't // get dereferenced, also we don't want one for every region. - final UDPDiscoveryAttributes udpAttributes = new UDPDiscoveryAttributes( - lac.getTcpListenerHost(), lac.getTcpListenerPort(), lac.getUdpDiscoveryAddr(), - lac.getUdpDiscoveryInterface(), lac.getUdpDiscoveryPort(), lac.getUdpTTL(), - UDPDiscoveryAttributes.defaults().maxIdleTimeSec()); + final UDPDiscoveryAttributes udpAttributes = new UDPDiscoveryAttributes(lac); - discovery = UDPDiscoveryManager.getInstance().getService(udpAttributes, cacheMgr, + UDPDiscoveryService discovery = UDPDiscoveryManager.getInstance().getService(udpAttributes, cacheMgr, elementSerializer); discovery.addParticipatingCacheName( lac.getCacheName() ); diff --git a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryAttributes.java b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryAttributes.java index dc8c63b6..b9f1a199 100644 --- a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryAttributes.java +++ b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/discovery/UDPDiscoveryAttributes.java @@ -19,6 +19,8 @@ package org.apache.commons.jcs4.utils.discovery; * under the License. */ +import org.apache.commons.jcs4.auxiliary.lateral.socket.tcp.behavior.ILateralTCPCacheAttributes; + /** * Configuration properties for UDP discover service. * <p> @@ -76,6 +78,18 @@ public record UDPDiscoveryAttributes( return DEFAULT; } + /** + * Constructor from ILateralTCPCacheAttributes + * + * @param lac lateral cache configuration object + */ + public UDPDiscoveryAttributes(ILateralTCPCacheAttributes lac) + { + this(lac.getTcpListenerHost(), lac.getTcpListenerPort(), lac.getUdpDiscoveryAddr(), + lac.getUdpDiscoveryInterface(), lac.getUdpDiscoveryPort(), lac.getUdpTTL(), + defaults().maxIdleTimeSec()); + } + /** * Constructor with necessary fields only *
