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
The following commit(s) were added to refs/heads/master by this push: new d6fb9ab JCS-210 - Replace Lambda with method reference new 273cb89 Merge pull request #34 from arturobernalg/feature/JCS-210 d6fb9ab is described below commit d6fb9ab094abf9dba9486c81e2da449a415be606 Author: Arturo Bernal <arturobern...@gmail.com> AuthorDate: Sun Mar 28 16:46:46 2021 +0200 JCS-210 - Replace Lambda with method reference --- .../jcs3/auxiliary/AbstractAuxiliaryCache.java | 3 +- .../jcs3/auxiliary/disk/AbstractDiskCache.java | 4 +-- .../jcs3/auxiliary/disk/block/BlockDisk.java | 2 +- .../jcs3/auxiliary/disk/block/BlockDiskCache.java | 12 +++---- .../auxiliary/disk/block/BlockDiskKeyStore.java | 8 ++--- .../auxiliary/disk/indexed/IndexedDiskCache.java | 12 +++---- .../jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java | 4 +-- .../jcs3/auxiliary/disk/jdbc/ShrinkerThread.java | 2 +- .../disk/jdbc/mysql/MySQLDiskCacheFactory.java | 2 +- .../disk/jdbc/mysql/MySQLTableOptimizer.java | 2 +- .../jcs3/auxiliary/lateral/LateralCacheNoWait.java | 2 +- .../lateral/LateralCacheNoWaitFacade.java | 7 ++-- .../lateral/socket/tcp/LateralTCPCacheFactory.java | 2 +- .../socket/tcp/LateralTCPDiscoveryListener.java | 4 +-- .../lateral/socket/tcp/LateralTCPListener.java | 12 +++---- .../lateral/socket/tcp/LateralTCPService.java | 2 +- .../remote/AbstractRemoteAuxiliaryCache.java | 4 +-- .../remote/AbstractRemoteCacheListener.java | 2 +- .../remote/RemoteCacheFailoverRunner.java | 6 ++-- .../jcs3/auxiliary/remote/RemoteCacheManager.java | 4 +-- .../jcs3/auxiliary/remote/RemoteCacheNoWait.java | 2 +- .../commons/jcs3/auxiliary/remote/RemoteUtils.java | 4 +-- .../remote/http/client/RemoteHttpCacheClient.java | 2 +- .../remote/http/client/RemoteHttpCacheFactory.java | 2 +- .../http/server/AbstractRemoteCacheService.java | 4 +-- .../auxiliary/remote/server/RemoteCacheServer.java | 4 +-- .../jcs3/engine/control/CompositeCache.java | 37 +++++++++++----------- .../jcs3/engine/control/CompositeCacheManager.java | 11 ++++--- .../jcs3/engine/memory/AbstractMemoryCache.java | 13 ++++---- .../jcs3/engine/memory/lru/LHMLRUMemoryCache.java | 2 +- .../engine/memory/shrinking/ShrinkerThread.java | 2 +- .../commons/jcs3/utils/access/JCSWorker.java | 8 ++--- .../utils/discovery/UDPDiscoverySenderThread.java | 8 ++--- .../jcs3/utils/discovery/UDPDiscoveryService.java | 6 ++-- .../commons/jcs3/utils/struct/AbstractLRUMap.java | 6 ++-- 35 files changed, 106 insertions(+), 101 deletions(-) diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java index d9df597..619f649 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java @@ -22,6 +22,7 @@ package org.apache.commons.jcs3.auxiliary; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -69,7 +70,7 @@ public abstract class AbstractAuxiliaryCache<K, V> return null; } }) - .filter(element -> element != null) + .filter(Objects::nonNull) .collect(Collectors.toMap( ICacheElement::getKey, element -> element)); diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCache.java index d7c7079..e7ad267 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCache.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCache.java @@ -191,7 +191,7 @@ public abstract class AbstractDiskCache<K, V> throws IOException { log.debug( "Putting element in purgatory, cacheName: {0}, key: {1}", - () -> cacheName, () -> cacheElement.getKey() ); + () -> cacheName, cacheElement::getKey); try { @@ -444,7 +444,7 @@ public abstract class AbstractDiskCache<K, V> if (shutdownSpoolTime <= 0) { log.info( "No longer waiting for event queue to finish: {0}", - () -> cacheEventQueue.getStatistics() ); + cacheEventQueue::getStatistics); } log.info( "In dispose, destroying event queue." ); diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDisk.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDisk.java index 7b0555c..93854ad 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDisk.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDisk.java @@ -288,7 +288,7 @@ public class BlockDisk implements AutoCloseable data.flip(); } - log.debug("read, total post combination data.length = {0}", () -> data.limit()); + log.debug("read, total post combination data.length = {0}", data::limit); return elementSerializer.deSerialize(data.array(), null); } diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java index 85fc988..835b3db 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java @@ -268,7 +268,7 @@ public class BlockDiskCache<K, V> final Map<K, ICacheElement<K, V>> elements = matchingKeys.stream() .collect(Collectors.toMap( key -> key, - key -> processGet( key ))).entrySet().stream() + this::processGet)).entrySet().stream() .filter(entry -> entry.getValue() != null) .collect(Collectors.toMap( Entry::getKey, @@ -357,7 +357,7 @@ public class BlockDiskCache<K, V> if ( !isAlive() ) { log.debug("{0}: No longer alive; aborting put of key = {1}", - () -> logCacheName, () -> element.getKey()); + () -> logCacheName, element::getKey); return; } @@ -380,7 +380,7 @@ public class BlockDiskCache<K, V> this.keyStore.put( element.getKey(), blocks ); log.debug("{0}: Put to file [{1}] key [{2}]", () -> logCacheName, - () -> fileName, () -> element.getKey()); + () -> fileName, element::getKey); } catch ( final IOException e ) { @@ -393,7 +393,7 @@ public class BlockDiskCache<K, V> } log.debug("{0}: Storing element on disk, key: {1}", () -> logCacheName, - () -> element.getKey() ); + element::getKey); } /** @@ -472,7 +472,7 @@ public class BlockDiskCache<K, V> // remove matches. // Don't add to recycle bin here // https://issues.apache.org/jira/browse/JCS-67 - itemsToRemove.forEach(fullKey -> performSingleKeyRemoval(fullKey)); + itemsToRemove.forEach(this::performSingleKeyRemoval); // TODO this needs to update the remove count separately return !itemsToRemove.isEmpty(); @@ -499,7 +499,7 @@ public class BlockDiskCache<K, V> // remove matches. // Don't add to recycle bin here // https://issues.apache.org/jira/browse/JCS-67 - itemsToRemove.forEach(fullKey -> performSingleKeyRemoval(fullKey)); + itemsToRemove.forEach(this::performSingleKeyRemoval); // TODO this needs to update the remove count separately return !itemsToRemove.isEmpty(); diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskKeyStore.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskKeyStore.java index 97873ce..9997620 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskKeyStore.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskKeyStore.java @@ -390,7 +390,7 @@ public class BlockDiskKeyStore<K> */ protected void loadKeys() { - log.info("{0}: Loading keys for {1}", () -> logCacheName, () -> keyFile.toString()); + log.info("{0}: Loading keys for {1}", () -> logCacheName, keyFile::toString); // create a key map to use. initKeyMap(); @@ -518,7 +518,7 @@ public class BlockDiskKeyStore<K> { final ElapsedTimer timer = new ElapsedTimer(); log.info("{0}: Saving keys to [{1}], key count [{2}]", () -> logCacheName, - () -> this.keyFile.getAbsolutePath(), () -> keyHash.size()); + this.keyFile::getAbsolutePath, () -> keyHash.size()); synchronized (keyFile) { @@ -554,8 +554,8 @@ public class BlockDiskKeyStore<K> } log.info("{0}: Finished saving keys. It took {1} to store {2} keys. Key file length [{3}]", - () -> logCacheName, () -> timer.getElapsedTimeString(), () -> keyHash.size(), - () -> keyFile.length()); + () -> logCacheName, timer::getElapsedTimeString, () -> keyHash.size(), + keyFile::length); } /** diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java index 4259df4..883516e 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java @@ -322,7 +322,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V> keyHash.putAll(keys); log.info("{0}: Loaded keys from [{1}], key count: {2}; up to {3} will be available.", - () -> logCacheName, () -> fileName, () -> keyHash.size(), () -> maxKeySize); + () -> logCacheName, () -> fileName, keyHash::size, () -> maxKeySize); } if (log.isTraceEnabled()) @@ -413,7 +413,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V> expectedNextPos = ded.pos + IndexedDisk.HEADER_SIZE_BYTES + ded.len; } log.debug("{0}: Check for DED overlaps took {1} ms.", () -> logCacheName, - () -> timer.getElapsedTime()); + timer::getElapsedTime); return isOk; } @@ -426,7 +426,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V> try { log.info("{0}: Saving keys to: {1}, key count: {2}", - () -> logCacheName, () -> fileName, () -> keyHash.size()); + () -> logCacheName, () -> fileName, keyHash::size); keyFile.reset(); @@ -458,12 +458,12 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V> if (!isAlive()) { log.error("{0}: No longer alive; aborting put of key = {1}", - () -> logCacheName, () -> ce.getKey()); + () -> logCacheName, ce::getKey); return; } log.debug("{0}: Storing element on disk, key: {1}", - () -> logCacheName, () -> ce.getKey()); + () -> logCacheName, ce::getKey); IndexedDiskElementDescriptor ded = null; @@ -517,7 +517,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V> { queuedPutList.add(ded); log.debug("{0}: added to queued put list. {1}", - () -> logCacheName, () -> queuedPutList.size()); + () -> logCacheName, queuedPutList::size); } // add the old slot to the recycle bin diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java index 4c8ede0..cc426dc 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java @@ -121,7 +121,7 @@ public class JDBCDiskCache<K, V> setTableState( tableState ); setJdbcDiskCacheAttributes( cattr ); - log.info( "jdbcDiskCacheAttributes = {0}", () -> getJdbcDiskCacheAttributes() ); + log.info( "jdbcDiskCacheAttributes = {0}", this::getJdbcDiskCacheAttributes); // This initializes the pool access. this.dsFactory = dsFactory; @@ -146,7 +146,7 @@ public class JDBCDiskCache<K, V> try (Connection con = getDataSource().getConnection()) { - log.debug( "Putting [{0}] on disk.", () -> ce.getKey()); + log.debug( "Putting [{0}] on disk.", ce::getKey); try { diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/ShrinkerThread.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/ShrinkerThread.java index b9e1b15..cf68789 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/ShrinkerThread.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/ShrinkerThread.java @@ -95,7 +95,7 @@ public class ShrinkerThread private void deleteExpiredFromAllRegisteredRegions() { log.info( "Running JDBC disk cache shrinker. Number of regions [{0}]", - () -> shrinkSet.size() ); + shrinkSet::size); for (final Iterator<JDBCDiskCache<?, ?>> i = shrinkSet.iterator(); i.hasNext();) { diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java index 100938f..c778d2b 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java @@ -94,7 +94,7 @@ public class MySQLDiskCacheFactory if ( attributes.getOptimizationSchedule() != null ) { log.info( "Will try to configure optimization for table [{0}] on schedule [{1}]", - () -> attributes.getTableName(), () -> attributes.getOptimizationSchedule()); + attributes::getTableName, attributes::getOptimizationSchedule); final MySQLTableOptimizer optimizer = new MySQLTableOptimizer( attributes, tableState, ds ); diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java index aa5b566..0f031a3 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java @@ -187,7 +187,7 @@ public class MySQLTableOptimizer tableState.setState( TableState.FREE ); log.info( "Optimization of table [{0}] took {1} ms.", - this::getTableName, () -> timer.getElapsedTime() ); + this::getTableName, timer::getElapsedTime); } return success; diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java index cc9e05b..589f9dc 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java @@ -171,7 +171,7 @@ public class LateralCacheNoWait<K, V> final Map<K, ICacheElement<K, V>> elements = keys.stream() .collect(Collectors.toMap( key -> key, - key -> get(key))).entrySet().stream() + this::get)).entrySet().stream() .filter(entry -> entry.getValue() != null) .collect(Collectors.toMap( Entry::getKey, diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java index f2f8d80..f432e8d 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.atomic.AtomicBoolean; @@ -199,7 +200,7 @@ public class LateralCacheNoWaitFacade<K, V> throws IOException { log.debug("updating through lateral cache facade, noWaits.length = {0}", - () -> noWaitSet.size()); + noWaitSet::size); for (final LateralCacheNoWait<K, V> nw : noWaitSet) { @@ -218,7 +219,7 @@ public class LateralCacheNoWaitFacade<K, V> { return noWaitSet.stream() .map(nw -> nw.get(key)) - .filter(obj -> obj != null) + .filter(Objects::nonNull) .findFirst() .orElse(null); } @@ -238,7 +239,7 @@ public class LateralCacheNoWaitFacade<K, V> final Map<K, ICacheElement<K, V>> elements = keys.stream() .collect(Collectors.toMap( key -> key, - key -> get(key))).entrySet().stream() + this::get)).entrySet().stream() .filter(entry -> entry.getValue() != null) .collect(Collectors.toMap( Entry::getKey, diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java index 7a4f35b..6ab4dfd 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java @@ -394,7 +394,7 @@ public class LateralTCPCacheFactory discovery.addDiscoveryListener( discoveryListener ); log.info( "Registered TCP lateral cache [{0}] with UDPDiscoveryService.", - () -> lac.getCacheName() ); + lac::getCacheName); } return discovery; } diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java index d1fe541..6bcfce5 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java @@ -163,7 +163,7 @@ public class LateralTCPDiscoveryListener { log.info( "addNoWait > Different nodes are configured differently " + "or region [{0}] is not yet used on this side.", - () -> noWait.getCacheName() ); + noWait::getCacheName); } return false; } @@ -193,7 +193,7 @@ public class LateralTCPDiscoveryListener { log.info( "addNoWait > Different nodes are configured differently " + "or region [{0}] is not yet used on this side.", - () -> noWait.getCacheName() ); + noWait::getCacheName); } return false; } diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java index 19dafc6..7cf7a9b 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java @@ -123,7 +123,7 @@ public class LateralTCPListener<K, V> newIns.init(); newIns.setCacheManager( cacheMgr ); - log.info("Created new listener {0}", () -> ilca.getTcpListenerPort()); + log.info("Created new listener {0}", ilca::getTcpListenerPort); return newIns; }); @@ -238,11 +238,11 @@ public class LateralTCPListener<K, V> { log.info( "Put Count (port {0}) = {1}", () -> getTcpLateralCacheAttributes().getTcpListenerPort(), - () -> getPutCnt() ); + this::getPutCnt); } log.debug( "handlePut> cacheName={0}, key={1}", - () -> element.getCacheName(), () -> element.getKey() ); + element::getCacheName, element::getKey); getCache( element.getCacheName() ).localUpdate( element ); } @@ -261,7 +261,7 @@ public class LateralTCPListener<K, V> removeCnt++; if ( log.isInfoEnabled() && getRemoveCnt() % 100 == 0 ) { - log.info( "Remove Count = {0}", () -> getRemoveCnt() ); + log.info( "Remove Count = {0}", this::getRemoveCnt); } log.debug( "handleRemove> cacheName={0}, key={1}", cacheName, key ); @@ -299,7 +299,7 @@ public class LateralTCPListener<K, V> { log.info( "Get Count (port {0}) = {1}", () -> getTcpLateralCacheAttributes().getTcpListenerPort(), - () -> getGetCnt() ); + this::getGetCnt); } log.debug( "handleGet> cacheName={0}, key={1}", cacheName, key ); @@ -323,7 +323,7 @@ public class LateralTCPListener<K, V> { log.info( "GetMatching Count (port {0}) = {1}", () -> getTcpLateralCacheAttributes().getTcpListenerPort(), - () -> getGetCnt() ); + this::getGetCnt); } log.debug( "handleGetMatching> cacheName={0}, pattern={1}", cacheName, pattern ); diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPService.java index e7ecd90..e29e182 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPService.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPService.java @@ -76,7 +76,7 @@ public class LateralTCPService<K, V> { sender = new LateralTCPSender( lca ); - log.debug( "Created sender to [{0}]", () -> lca.getTcpServer() ); + log.debug( "Created sender to [{0}]", lca::getTcpServer); } catch ( final IOException e ) { diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java index 5445f97..9e41ab5 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java @@ -99,8 +99,8 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V> if ( log.isDebugEnabled() ) { - log.debug( "Construct> cacheName={0}", () -> cattr.getCacheName() ); - log.debug( "irca = {0}", () -> getRemoteCacheAttributes() ); + log.debug( "Construct> cacheName={0}", cattr::getCacheName); + log.debug( "irca = {0}", this::getRemoteCacheAttributes); log.debug( "remote = {0}", remote ); log.debug( "listener = {0}", listener ); } diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheListener.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheListener.java index 6eaf2b9..1b8a249 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheListener.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheListener.java @@ -118,7 +118,7 @@ public abstract class AbstractRemoteCacheListener<K, V> public RemoteType getRemoteType() throws IOException { - log.debug( "getRemoteType = [{0}]", () -> irca.getRemoteType() ); + log.debug( "getRemoteType = [{0}]", irca::getRemoteType); return irca.getRemoteType(); } diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFailoverRunner.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFailoverRunner.java index 5d07111..a88b6a5 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFailoverRunner.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFailoverRunner.java @@ -163,7 +163,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit final int fidx = rca0.getFailoverIndex(); log.debug( "fidx = {0} failovers.size = {1}", () -> fidx, - () -> failovers.size() ); + failovers::size); // shouldn't we see if the primary is backup? // If we don't check the primary, if it gets connected in the @@ -209,7 +209,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit allright.set(true); log.info( "CONNECTED to host = [{0}]", - () -> rca.getRemoteLocation() ); + rca::getRemoteLocation); } } } @@ -222,7 +222,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit log.debug( "ALLRIGHT is true " ); log.info( "Failover runner is in primary recovery mode. " + "Failover index = {0} Will now try to reconnect to " - + "primary server.", () -> rca0.getFailoverIndex() ); + + "primary server.", rca0::getFailoverIndex); } boolean primaryRestoredSuccessfully = false; diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java index 1f47feb..84fae9a 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java @@ -209,7 +209,7 @@ public class RemoteCacheManager { final IRemoteCacheClient<?, ?> rc = cache.getRemoteCache(); log.debug( "Found cache for [{0}], deregistering listener.", - () -> cache.getCacheName() ); + cache::getCacheName); // could also store the listener for a server in the manager. final IRemoteCacheListener<?, ?> listener = rc.getListener(); remoteWatch.removeCacheListener( cache.getCacheName(), listener ); @@ -277,7 +277,7 @@ public class RemoteCacheManager { try { - log.info( "freeCache [{0}]", () -> c.getCacheName() ); + log.info( "freeCache [{0}]", c::getCacheName); removeListenerFromCache(c); c.dispose(); diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWait.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWait.java index dfdc0ec..517a47f 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWait.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWait.java @@ -413,7 +413,7 @@ public class RemoteCacheNoWait<K, V> { // we don't expect anything, it would have all gone to the zombie log.info( "resetEventQ, previous queue has [{0}] items queued up.", - () -> previousQueue.size() ); + previousQueue::size); previousQueue.destroy(); } } diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java index fbb3de2..4244c91 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java @@ -145,7 +145,7 @@ public class RemoteUtils try { props.load(is); - log.debug("props.size={0}", () -> props.size()); + log.debug("props.size={0}", props::size); if (log.isTraceEnabled()) { @@ -220,7 +220,7 @@ public class RemoteUtils if (factoryInUse != null && !factoryInUse.getClass().getName().startsWith("org.apache.commons.jcs3")) { log.info("Could not create new custom socket factory. {0} Factory in use = {1}", - () -> e.getMessage(), RMISocketFactory::getSocketFactory); + e::getMessage, RMISocketFactory::getSocketFactory); } } } diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheClient.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheClient.java index 5f84bd7..33965a0 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheClient.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheClient.java @@ -78,7 +78,7 @@ public class RemoteHttpCacheClient<K, V> { setRemoteDispatcher( new RemoteHttpCacheDispatcher( attributes ) ); - log.info( "Created remote Dispatcher. {0}", () -> getRemoteDispatcher() ); + log.info( "Created remote Dispatcher. {0}", this::getRemoteDispatcher); setInitialized( true ); } diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheFactory.java index 7b83103..4f083d9 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheFactory.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheFactory.java @@ -101,7 +101,7 @@ public class RemoteHttpCacheFactory if ( remoteService == null ) { log.info( "Creating the default client for {0}", - () -> cattr.getCacheName()); + cattr::getCacheName); remoteService = new RemoteHttpCacheClient<>(); } diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/AbstractRemoteCacheService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/AbstractRemoteCacheService.java index b11dcfd..d13db13 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/AbstractRemoteCacheService.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/AbstractRemoteCacheService.java @@ -133,8 +133,8 @@ public abstract class AbstractRemoteCacheService<K, V> } } - log.debug( "In update, put [{0}] in [{1}]", () -> item.getKey(), - () -> item.getCacheName() ); + log.debug( "In update, put [{0}] in [{1}]", item::getKey, + item::getCacheName); } /** diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/server/RemoteCacheServer.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/server/RemoteCacheServer.java index f690300..291de08 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/server/RemoteCacheServer.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/server/RemoteCacheServer.java @@ -336,7 +336,7 @@ public class RemoteCacheServer<K, V> } // TODO use JAMON for timing - log.debug( "put took {0} ms.", () -> timer.getElapsedTime()); + log.debug( "put took {0} ms.", timer::getElapsedTime); } /** @@ -355,7 +355,7 @@ public class RemoteCacheServer<K, V> } log.debug( "In update, put [{0}] in [{1}]", - () -> item.getKey(), () -> item.getCacheName() ); + item::getKey, item::getCacheName); } /** diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCache.java index d975a89..84e7218 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCache.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCache.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ScheduledExecutorService; @@ -196,7 +197,7 @@ public class CompositeCache<K, V> public void setAuxCaches(final List<AuxiliaryCache<K, V>> auxCaches) { this.auxCaches = auxCaches.stream() - .filter(aux -> aux != null) + .filter(Objects::nonNull) .collect(Collectors.toCollection(CopyOnWriteArrayList::new)); } @@ -283,7 +284,7 @@ public class CompositeCache<K, V> throw new IllegalArgumentException("key cannot be a GroupId " + " for a put operation"); } - log.debug("Updating memory cache {0}", () -> cacheElement.getKey()); + log.debug("Updating memory cache {0}", cacheElement::getKey); updateCount.incrementAndGet(); memCache.update(cacheElement); @@ -370,7 +371,7 @@ public class CompositeCache<K, V> // Currently always multicast even if the value is // unchanged, to cause the cache item to move to the front. aux.update(cacheElement); - log.debug("updated lateral cache for {0}", () -> cacheElement.getKey()); + log.debug("updated lateral cache for {0}", cacheElement::getKey); } break; @@ -382,7 +383,7 @@ public class CompositeCache<K, V> && cacheElement.getElementAttributes().getIsSpool()) { aux.update(cacheElement); - log.debug("updated disk cache for {0}", () -> cacheElement.getKey()); + log.debug("updated disk cache for {0}", cacheElement::getKey); } break; @@ -436,7 +437,7 @@ public class CompositeCache<K, V> } log.debug("spoolToDisk done for: {0} on disk cache[{1}]", - () -> ce.getKey(), () -> aux.getCacheName()); + ce::getKey, aux::getCacheName); } else { @@ -532,7 +533,7 @@ public class CompositeCache<K, V> if (!localOnly || cacheType == CacheType.DISK_CACHE) { log.debug("Attempting to get from aux [{0}] which is of type: {1}", - () -> aux.getCacheName(), () -> cacheType); + aux::getCacheName, () -> cacheType); try { @@ -552,7 +553,7 @@ public class CompositeCache<K, V> if (isExpired(element)) { log.debug("{0} - Aux cache[{1}] hit, but element expired.", - () -> cacheAttr.getCacheName(), () -> aux.getCacheName()); + () -> cacheAttr.getCacheName(), aux::getCacheName); // This will tell the remotes to remove the item // based on the element's expiration policy. The elements attributes @@ -564,7 +565,7 @@ public class CompositeCache<K, V> else { log.debug("{0} - Aux cache[{1}] hit.", - () -> cacheAttr.getCacheName(), () -> aux.getCacheName()); + () -> cacheAttr.getCacheName(), aux::getCacheName); // Update counters hitCountAux.incrementAndGet(); @@ -732,7 +733,7 @@ public class CompositeCache<K, V> if (!localOnly || cacheType == CacheType.DISK_CACHE) { log.debug("Attempting to get from aux [{0}] which is of type: {1}", - () -> aux.getCacheName(), () -> cacheType); + aux::getCacheName, () -> cacheType); try { @@ -871,7 +872,7 @@ public class CompositeCache<K, V> if (!localOnly || cacheType == CacheType.DISK_CACHE) { log.debug("Attempting to get from aux [{0}] which is of type: {1}", - () -> aux.getCacheName(), () -> cacheType); + aux::getCacheName, () -> cacheType); try { @@ -911,7 +912,7 @@ public class CompositeCache<K, V> if (isExpired(element)) { log.debug("{0} - Aux cache[{1}] hit, but element expired.", - () -> cacheAttr.getCacheName(), () -> aux.getCacheName()); + () -> cacheAttr.getCacheName(), aux::getCacheName); // This will tell the remote caches to remove the item // based on the element's expiration policy. The elements attributes @@ -921,7 +922,7 @@ public class CompositeCache<K, V> return true; } log.debug("{0} - Aux cache[{1}] hit.", - () -> cacheAttr.getCacheName(), () -> aux.getCacheName()); + () -> cacheAttr.getCacheName(), aux::getCacheName); // Update counters hitCountAux.incrementAndGet(); @@ -1154,7 +1155,7 @@ public class CompositeCache<K, V> try { log.debug("Removing All keys from cacheType {0}", - () -> aux.getCacheType()); + aux::getCacheType); aux.removeAll(); } @@ -1226,13 +1227,13 @@ public class CompositeCache<K, V> || fromRemote && aux.getCacheType() == CacheType.REMOTE_CACHE) { log.info("In DISPOSE, [{0}] SKIPPING auxiliary [{1}] fromRemote [{2}]", - () -> this.cacheAttr.getCacheName(), () -> aux.getCacheName(), + () -> this.cacheAttr.getCacheName(), aux::getCacheName, () -> fromRemote); continue; } log.info("In DISPOSE, [{0}] auxiliary [{1}]", - () -> this.cacheAttr.getCacheName(), () -> aux.getCacheName()); + () -> this.cacheAttr.getCacheName(), aux::getCacheName); // IT USED TO BE THE CASE THAT (If the auxiliary is not a lateral, or the cache // attributes @@ -1247,7 +1248,7 @@ public class CompositeCache<K, V> log.info("In DISPOSE, [{0}] put {1} into auxiliary [{2}]", () -> this.cacheAttr.getCacheName(), () -> numToFree, - () -> aux.getCacheName()); + aux::getCacheName); } // Dispose of the auxiliary @@ -1502,7 +1503,7 @@ public class CompositeCache<K, V> if (maxLifeSeconds != -1 && (timestamp - createTime) > (maxLifeSeconds * timeFactorForMilliseconds)) { - log.debug("Exceeded maxLife: {0}", () -> element.getKey()); + log.debug("Exceeded maxLife: {0}", element::getKey); handleElementEvent(element, eventMaxlife); return true; @@ -1516,7 +1517,7 @@ public class CompositeCache<K, V> // you will need to set the idle time to -1. if (idleTime != -1 && timestamp - lastAccessTime > idleTime * timeFactorForMilliseconds) { - log.debug("Exceeded maxIdle: {0}", () -> element.getKey()); + log.debug("Exceeded maxIdle: {0}", element::getKey); handleElementEvent(element, eventIdle); return true; diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheManager.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheManager.java index 9785e8f..80d44a9 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheManager.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheManager.java @@ -25,6 +25,7 @@ import java.lang.management.ManagementFactory; import java.security.AccessControlException; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -325,7 +326,7 @@ public class CompositeCacheManager try (InputStream is = getClass().getResourceAsStream( propFile )) { props.load( is ); - log.debug( "File [{0}] contained {1} properties", () -> propFile, () -> props.size()); + log.debug( "File [{0}] contained {1} properties", () -> propFile, props::size); } catch ( final IOException ex ) { @@ -453,7 +454,7 @@ public class CompositeCacheManager // setup preconfigured caches configurator.parseRegions( properties, this ); - log.info( "Finished configuration in {0} ms.", () -> timer.getElapsedTime()); + log.info( "Finished configuration in {0} ms.", timer::getElapsedTime); isConfigured = true; } @@ -687,10 +688,10 @@ public class CompositeCacheManager } log.debug( "Last client called release. There are {0} caches which will be disposed", - () -> caches.size()); + caches::size); caches.values().stream() - .filter(cache -> cache != null) + .filter(Objects::nonNull) .forEach(cache -> { ((CompositeCache<?, ?>)cache).dispose( fromRemote ); }); @@ -849,7 +850,7 @@ public class CompositeCacheManager public ICacheStats[] getStatistics() { final List<ICacheStats> cacheStats = caches.values().stream() - .filter(cache -> cache != null) + .filter(Objects::nonNull) .map(cache -> ((CompositeCache<?, ?>)cache).getStatistics() ) .collect(Collectors.toList()); diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractMemoryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractMemoryCache.java index 7609fd1..4481bc7 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractMemoryCache.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractMemoryCache.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.Lock; @@ -129,7 +130,7 @@ public abstract class AbstractMemoryCache<K, V> return null; } }) - .filter(element -> element != null) + .filter(Objects::nonNull) .collect(Collectors.toMap( ICacheElement::getKey, element -> element)); @@ -156,14 +157,14 @@ public abstract class AbstractMemoryCache<K, V> if ( me != null ) { log.debug( "{0}: MemoryCache quiet hit for {1}", - () -> getCacheName(), () -> key ); + this::getCacheName, () -> key ); ce = me.getCacheElement(); } else { log.debug( "{0}: MemoryCache quiet miss for {1}", - () -> getCacheName(), () -> key ); + this::getCacheName, () -> key ); } return ce; @@ -469,7 +470,7 @@ public abstract class AbstractMemoryCache<K, V> { ICacheElement<K, V> ce = null; - log.debug("{0}: getting item for key {1}", () -> getCacheName(), + log.debug("{0}: getting item for key {1}", this::getCacheName, () -> key); final MemoryElementDescriptor<K, V> me = map.get(key); @@ -489,14 +490,14 @@ public abstract class AbstractMemoryCache<K, V> lock.unlock(); } - log.debug("{0}: MemoryCache hit for {1}", () -> getCacheName(), + log.debug("{0}: MemoryCache hit for {1}", this::getCacheName, () -> key); } else { missCnt.incrementAndGet(); - log.debug("{0}: MemoryCache miss for {1}", () -> getCacheName(), + log.debug("{0}: MemoryCache miss for {1}", this::getCacheName, () -> key); } diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/lru/LHMLRUMemoryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/lru/LHMLRUMemoryCache.java index 6bc9877..2aceeaf 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/lru/LHMLRUMemoryCache.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/lru/LHMLRUMemoryCache.java @@ -188,7 +188,7 @@ public class LHMLRUMemoryCache<K, V> return false; } log.debug( "LHMLRU max size: {0}. Spooling element, key: {1}", - () -> getCacheAttributes().getMaxObjects(), () -> element.getKey() ); + () -> getCacheAttributes().getMaxObjects(), element::getKey); waterfal( element ); diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/shrinking/ShrinkerThread.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/shrinking/ShrinkerThread.java index 89db6e9..61a06d2 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/shrinking/ShrinkerThread.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/shrinking/ShrinkerThread.java @@ -106,7 +106,7 @@ public class ShrinkerThread<K, V> */ protected void shrink() { - log.debug( "Shrinking memory cache for: {0}", () -> this.cache.getCacheName() ); + log.debug( "Shrinking memory cache for: {0}", this.cache::getCacheName); final IMemoryCache<K, V> memCache = cache.getMemoryCache(); diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/access/JCSWorker.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/access/JCSWorker.java index 96cd113..aad18b7 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/access/JCSWorker.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/access/JCSWorker.java @@ -215,7 +215,7 @@ public class JCSWorker<K, V> synchronized ( helper ) { logger.debug( "Found a worker already doing this work ({0}:{1}).", - () -> getRegion(), () -> aKey ); + this::getRegion, () -> aKey ); while ( !helper.isFinished() ) { try @@ -229,13 +229,13 @@ public class JCSWorker<K, V> } logger.debug( "Another thread finished our work for us. Using " + "those results instead. ({0}:{1}).", - () -> getRegion(), () -> aKey ); + this::getRegion, () -> aKey ); } } // Do the work try { - logger.debug( "{0} is doing the work.", () -> getRegion() ); + logger.debug( "{0} is doing the work.", this::getRegion); // Try to get the item from the cache if ( aGroup != null ) @@ -267,7 +267,7 @@ public class JCSWorker<K, V> } finally { - logger.debug( "{0}:{1} entered finally.", () -> getRegion(), + logger.debug( "{0}:{1} entered finally.", this::getRegion, () -> aKey ); // Remove ourselves as the worker. diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoverySenderThread.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoverySenderThread.java index 1204e69..39d226c 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoverySenderThread.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoverySenderThread.java @@ -76,10 +76,10 @@ public class UDPDiscoverySenderThread log.debug( "Creating sender thread for discoveryAddress = [{0}] and " + "discoveryPort = [{1}] myHostName = [{2}] and port = [{3}]", - () -> attributes.getUdpDiscoveryAddr(), - () -> attributes.getUdpDiscoveryPort(), - () -> attributes.getServiceAddress(), - () -> attributes.getServicePort() ); + attributes::getUdpDiscoveryAddr, + attributes::getUdpDiscoveryPort, + attributes::getServiceAddress, + attributes::getServicePort); try (UDPDiscoverySender sender = new UDPDiscoverySender( attributes.getUdpDiscoveryAddr(), diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryService.java index bb7b9e5..4a8a1ac 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryService.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryService.java @@ -146,14 +146,14 @@ public class UDPDiscoveryService public void setScheduledExecutorService(final ScheduledExecutorService scheduledExecutor) { this.broadcastTaskFuture = scheduledExecutor.scheduleAtFixedRate( - () -> serviceRequestBroadcast(), 0, 15, TimeUnit.SECONDS); + this::serviceRequestBroadcast, 0, 15, TimeUnit.SECONDS); /** removes things that have been idle for too long */ // I'm going to use this as both, but it could happen // that something could hang around twice the time using this as the // delay and the idle time. this.cleanupTaskFuture = scheduledExecutor.scheduleAtFixedRate( - () -> cleanup(), 0, + this::cleanup, 0, getUdpDiscoveryAttributes().getMaxIdleTimeSec(), TimeUnit.SECONDS); } @@ -180,7 +180,7 @@ public class UDPDiscoveryService }) // remove the bad ones // call this so the listeners get notified - .forEach(service -> removeDiscoveredService(service)); + .forEach(this::removeDiscoveredService); } /** diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/struct/AbstractLRUMap.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/struct/AbstractLRUMap.java index c744d7e..c554cea 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/struct/AbstractLRUMap.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/struct/AbstractLRUMap.java @@ -326,7 +326,7 @@ public abstract class AbstractLRUMap<K, V> if (map.remove(last.getKey()) == null) { log.warn("update: remove failed for key: {0}", - () -> last.getKey()); + last::getKey); verifyCache(); } list.removeLast(); @@ -337,12 +337,12 @@ public abstract class AbstractLRUMap<K, V> } } - log.debug( "update: After spool map size: {0}", () -> map.size() ); + log.debug( "update: After spool map size: {0}", map::size); if ( map.size() != list.size() ) { log.error("update: After spool, size mismatch: map.size() = {0}, " + "linked list size = {1}", - () -> map.size(), () -> list.size()); + map::size, list::size); } }