You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tv...@apache.org on 2023/08/24 21:58:37 UTC
[commons-jcs] branch master updated: Let Eclipse cleanup code
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 01c39c63 Let Eclipse cleanup code
01c39c63 is described below
commit 01c39c632df1362d2956c2cf557ca4b35c4f4643
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Thu Aug 24 23:58:32 2023 +0200
Let Eclipse cleanup code
---
.../auxiliary/disk/indexed/IndexedDiskCache.java | 5 +--
.../jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java | 17 ++++++----
.../jcs3/auxiliary/lateral/LateralCache.java | 2 +-
.../lateral/socket/tcp/LateralTCPListener.java | 2 +-
.../remote/AbstractRemoteCacheNoWaitFacade.java | 2 +-
.../jcs3/auxiliary/remote/RemoteCacheListener.java | 2 +-
.../jcs3/auxiliary/remote/RemoteCacheManager.java | 7 ++--
.../auxiliary/remote/RemoteCacheNoWaitFacade.java | 14 ++++----
.../jcs3/utils/discovery/DiscoveredService.java | 6 +---
.../commons/jcs3/admin/CountingStreamUnitTest.java | 4 +--
.../disk/block/AbstractBlockDiskCacheUnitTest.java | 2 +-
.../jcs3/auxiliary/disk/jdbc/HsqlSetupUtil.java | 2 +-
.../lateral/socket/tcp/TestTCPLateralUnitTest.java | 4 +--
.../auxiliary/remote/TestRemoteCacheFactory.java | 5 +--
.../jcs3/utils/access/JCSWorkerUnitTest.java | 2 +-
.../UDPDiscoverySenderEncryptedUnitTest.java | 38 ++++------------------
.../CompressingSerializerUnitTest.java | 11 ++++---
.../commons/jcs3/jcache/extras/cdi/AnyLiteral.java | 1 +
.../jcs3/jcache/extras/cdi/DefaultLiteral.java | 1 +
.../jcache/extras/cdi/ExtraJCacheExtension.java | 14 ++------
.../jcache/extras/loader/CacheLoaderAdapter.java | 2 ++
.../jcache/extras/loader/CompositeCacheLoader.java | 1 +
.../jcs3/jcache/extras/web/InMemoryResponse.java | 4 ++-
.../jcs3/jcache/extras/web/JCacheFilter.java | 11 +++----
.../jcache/extras/writer/AsyncCacheWriter.java | 2 ++
.../jcache/extras/writer/CacheWriterAdapter.java | 2 ++
.../jcache/extras/writer/CompositeCacheWriter.java | 1 +
.../extras/loader/CacheLoaderAdapterTest.java | 2 ++
.../extras/loader/CompositeCacheLoaderTest.java | 8 +++--
.../extras/writer/CacheWriterAdapterTest.java | 6 +++-
.../extras/writer/CompositeCacheWriterTest.java | 8 +++--
.../jcache/openjpa/OpenJPAJCacheDataCache.java | 2 ++
.../openjpa/OpenJPAJCacheDataCacheManager.java | 24 +++++++-------
.../jcache/openjpa/OpenJPAJCacheQueryCache.java | 1 +
.../jcache/openjpa/OpenJPAJCacheDataCacheTest.java | 4 ++-
.../jcache/EnsureCDIIsTestedWhenTCKsRunTest.java | 11 ++++---
.../org/apache/commons/jcs3/jcache/JCSCache.java | 14 ++++----
.../commons/jcs3/jcache/JCSCachingManager.java | 32 +++++++++---------
.../jcache/cdi/CacheInvocationContextImpl.java | 2 +-
.../jmx/ConfigurableMBeanServerIdBuilder.java | 2 +-
.../org/apache/commons/jcs3/jcache/CacheTest.java | 4 +--
.../commons/jcs3/jcache/ExpiryListenerTest.java | 3 +-
.../commons/jcs3/jcache/ImmediateExpiryTest.java | 7 ++--
.../jcs3/jcache/cdi/CDIJCacheHelperTest.java | 1 +
44 files changed, 146 insertions(+), 149 deletions(-)
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
index 2f9a4dc3..a779c8fa 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
@@ -25,6 +25,7 @@ import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -173,7 +174,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
// Make a clean file name
this.fileName = getCacheName().replaceAll("[^a-zA-Z0-9-_\\.]", "_");
this.keyHash = createInitialKeyMap();
- this.queuedPutList = new ConcurrentSkipListSet<>((ded1, ded2) -> Long.compare(ded1.pos, ded2.pos));
+ this.queuedPutList = new ConcurrentSkipListSet<>(Comparator.comparing(ded1 -> ded1.pos));
this.recycle = new ConcurrentSkipListSet<>();
try
@@ -1250,7 +1251,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
private Collection<IndexedDiskElementDescriptor> createPositionSortedDescriptorList()
{
final List<IndexedDiskElementDescriptor> defragList = new ArrayList<>(keyHash.values());
- Collections.sort(defragList, (ded1, ded2) -> Long.compare(ded1.pos, ded2.pos));
+ Collections.sort(defragList, Comparator.comparing(ded1 -> ded1.pos));
return defragList;
}
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java
index 6ef5d374..b3a80c46 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java
@@ -201,10 +201,11 @@ public class JDBCDiskCache<K, V>
private boolean insertRow( final ICacheElement<K, V> ce, final Connection con, final byte[] element )
{
boolean exists = false;
- final String sqlI = String.format("insert into %s"
- + " (CACHE_KEY, REGION, ELEMENT, MAX_LIFE_SECONDS, IS_ETERNAL, CREATE_TIME, UPDATE_TIME_SECONDS,"
- + " SYSTEM_EXPIRE_TIME_SECONDS) "
- + " values (?, ?, ?, ?, ?, ?, ?, ?)", getJdbcDiskCacheAttributes().getTableName());
+ final String sqlI = String.format("""
+ insert into %s\
+ (CACHE_KEY, REGION, ELEMENT, MAX_LIFE_SECONDS, IS_ETERNAL, CREATE_TIME, UPDATE_TIME_SECONDS,\
+ SYSTEM_EXPIRE_TIME_SECONDS)\s\
+ values (?, ?, ?, ?, ?, ?, ?, ?)""", getJdbcDiskCacheAttributes().getTableName());
try (PreparedStatement psInsert = con.prepareStatement( sqlI ))
{
@@ -255,9 +256,11 @@ public class JDBCDiskCache<K, V>
*/
private void updateRow( final ICacheElement<K, V> ce, final Connection con, final byte[] element )
{
- final String sqlU = String.format("update %s"
- + " set ELEMENT = ?, CREATE_TIME = ?, UPDATE_TIME_SECONDS = ?, " + " SYSTEM_EXPIRE_TIME_SECONDS = ? "
- + " where CACHE_KEY = ? and REGION = ?", getJdbcDiskCacheAttributes().getTableName());
+ final String sqlU = String.format("""
+ update %s\
+ set ELEMENT = ?, CREATE_TIME = ?, UPDATE_TIME_SECONDS = ?,\s\
+ SYSTEM_EXPIRE_TIME_SECONDS = ?\s\
+ where CACHE_KEY = ? and REGION = ?""", getJdbcDiskCacheAttributes().getTableName());
try (PreparedStatement psUpdate = con.prepareStatement( sqlU ))
{
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java
index 53142461..6a2f8370 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java
@@ -56,7 +56,7 @@ public class LateralCache<K, V>
private ICacheServiceNonLocal<K, V> lateralCacheService;
/** Monitors the connection. */
- private LateralCacheMonitor monitor;
+ private final LateralCacheMonitor monitor;
/**
* Constructor for the LateralCache object
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
index 28c94b53..ddd8e6ac 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
@@ -74,7 +74,7 @@ public class LateralTCPListener<K, V>
/**
* Serializer for reading and writing
*/
- private IElementSerializer serializer;
+ private final IElementSerializer serializer;
/** put count */
private int putCnt;
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java
index 9a42f2f6..820caff1 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java
@@ -254,7 +254,7 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
public CacheStatus getStatus()
{
return noWaits.stream()
- .map(nw -> nw.getStatus())
+ .map(RemoteCacheNoWait::getStatus)
.filter(status -> status == CacheStatus.ALIVE)
.findFirst()
.orElse(CacheStatus.DISPOSED);
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheListener.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheListener.java
index 5e094cfa..6889cf8d 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheListener.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheListener.java
@@ -46,7 +46,7 @@ public class RemoteCacheListener<K, V>
private static final Log log = LogManager.getLog( RemoteCacheListener.class );
/** Has this client been shutdown. */
- private AtomicBoolean disposed;
+ private final AtomicBoolean disposed;
/**
* Only need one since it does work for all regions, just reference by multiple region names.
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java
index 25e0430f..11af1ca6 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java
@@ -160,9 +160,10 @@ public class RemoteCacheManager
{
if ( cattr.isReceive() )
{
- log.info( "The remote cache is configured to receive events from the remote server. "
- + "We will register a listener. remoteWatch = {0} | IRemoteCacheListener = {1}"
- + " | cacheName ", remoteWatch, listener, cattr.getCacheName() );
+ log.info( """
+ The remote cache is configured to receive events from the remote server.\s\
+ We will register a listener. remoteWatch = {0} | IRemoteCacheListener = {1}\
+ | cacheName\s""", remoteWatch, listener, cattr.getCacheName() );
remoteWatch.addCacheListener( cattr.getCacheName(), listener );
}
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWaitFacade.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWaitFacade.java
index 9f2e0150..95375abe 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWaitFacade.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWaitFacade.java
@@ -216,9 +216,10 @@ public class RemoteCacheNoWaitFacade<K, V>
else
{
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);
+ log.info( """
+ Failover runner is in primary recovery mode.\s\
+ Failover index = {0} Will now try to reconnect to\s\
+ primary server.""", rca0::getFailoverIndex);
}
// Exit loop if in test mode
@@ -241,9 +242,10 @@ public class RemoteCacheNoWaitFacade<K, V>
// Time driven mode: sleep between each round of recovery attempt.
try
{
- log.warn( "Failed to reconnect to primary server. "
- + "Cache failover runner is going to sleep for "
- + "{0} milliseconds.", idlePeriod );
+ log.warn( """
+ Failed to reconnect to primary server.\s\
+ Cache failover runner is going to sleep for\s\
+ {0} milliseconds.""", idlePeriod );
Thread.sleep( idlePeriod );
}
catch ( final InterruptedException ex )
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/utils/discovery/DiscoveredService.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/utils/discovery/DiscoveredService.java
index d97e6ddb..1c01c9aa 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/utils/discovery/DiscoveredService.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/utils/discovery/DiscoveredService.java
@@ -155,11 +155,7 @@ public class DiscoveredService
{
return true;
}
- if (otherArg == null)
- {
- return false;
- }
- if (!(otherArg instanceof DiscoveredService))
+ if ((otherArg == null) || !(otherArg instanceof DiscoveredService))
{
return false;
}
diff --git a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/admin/CountingStreamUnitTest.java b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/admin/CountingStreamUnitTest.java
index 2ceae483..0b9f4e6f 100644
--- a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/admin/CountingStreamUnitTest.java
+++ b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/admin/CountingStreamUnitTest.java
@@ -53,7 +53,7 @@ public class CountingStreamUnitTest
public void testByteArray() throws Exception
{
final CountingOnlyOutputStream out = new CountingOnlyOutputStream();
- final byte[] array = new byte[]{1,2,3,4,5};
+ final byte[] array = {1,2,3,4,5};
out.write( array );
assertEquals( "Wrong number of bytes written.", array.length, out.getCount() );
out.close();
@@ -67,7 +67,7 @@ public class CountingStreamUnitTest
public void testByteArrayLenCount() throws Exception
{
final CountingOnlyOutputStream out = new CountingOnlyOutputStream();
- final byte[] array = new byte[]{1,2,3,4,5};
+ final byte[] array = {1,2,3,4,5};
final int len = 3;
out.write( array, 0, len );
assertEquals( "Wrong number of bytes written.", len, out.getCount() );
diff --git a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/block/AbstractBlockDiskCacheUnitTest.java b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/block/AbstractBlockDiskCacheUnitTest.java
index be70a4c0..5f0a6eb1 100644
--- a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/block/AbstractBlockDiskCacheUnitTest.java
+++ b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/block/AbstractBlockDiskCacheUnitTest.java
@@ -129,7 +129,7 @@ public abstract class AbstractBlockDiskCacheUnitTest extends TestCase
// get the individual sub arrays.
final byte[][] chunks = blockDisk.getBlockChunks(data, numBlocksNeeded);
- byte[] resultData = new byte[0];
+ byte[] resultData = {};
for (short i = 0; i < chunks.length; i++)
{
diff --git a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/HsqlSetupUtil.java b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/HsqlSetupUtil.java
index e933b17e..b3f0bad6 100644
--- a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/HsqlSetupUtil.java
+++ b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/HsqlSetupUtil.java
@@ -36,7 +36,7 @@ public final class HsqlSetupUtil
{
super.setupTable(cConn, tableName);
}
- };
+ }
private static HSQLDiskCacheFactoryHelper factory = new HSQLDiskCacheFactoryHelper();
diff --git a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/TestTCPLateralUnitTest.java b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/TestTCPLateralUnitTest.java
index dcb92480..9d6bbc11 100644
--- a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/TestTCPLateralUnitTest.java
+++ b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/TestTCPLateralUnitTest.java
@@ -100,7 +100,7 @@ public class TestTCPLateralUnitTest
{
simpleSend(new StandardSerializer(), 8111);
}
-
+
/**
* @throws Exception
*/
@@ -111,7 +111,7 @@ public class TestTCPLateralUnitTest
serializer.setPreSharedKey("my_key");
simpleSend(serializer, 8112);
}
-
+
private void simpleSend(final IElementSerializer serializer, final int port ) throws IOException {
// SETUP
// force initialization
diff --git a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/remote/TestRemoteCacheFactory.java b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/remote/TestRemoteCacheFactory.java
index 5620aad7..ba54a504 100644
--- a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/remote/TestRemoteCacheFactory.java
+++ b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/auxiliary/remote/TestRemoteCacheFactory.java
@@ -84,10 +84,7 @@ public class TestRemoteCacheFactory extends RemoteCacheFactory
rca.setRemoteLocation("", Registry.REGISTRY_PORT);
}
- return managers.computeIfAbsent(rca.getRemoteLocation(), key -> {
-
- return new TestRemoteCacheManager(rca, cacheMgr, null, cacheEventLogger, elementSerializer);
- });
+ return managers.computeIfAbsent(rca.getRemoteLocation(), key -> new TestRemoteCacheManager(rca, cacheMgr, null, cacheEventLogger, elementSerializer));
}
/**
diff --git a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/access/JCSWorkerUnitTest.java b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/access/JCSWorkerUnitTest.java
index 634c0bee..fc128eec 100644
--- a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/access/JCSWorkerUnitTest.java
+++ b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/access/JCSWorkerUnitTest.java
@@ -44,7 +44,7 @@ public class JCSWorkerUnitTest
final JCSWorker<String, Long> cachingWorker = new JCSWorker<>( "example region" );
// This is the helper.
- final JCSWorkerHelper<Long> helper = new AbstractJCSWorkerHelper<Long>()
+ final JCSWorkerHelper<Long> helper = new AbstractJCSWorkerHelper<>()
{
int timesCalled;
diff --git a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoverySenderEncryptedUnitTest.java b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoverySenderEncryptedUnitTest.java
index bb462ef3..1a795137 100644
--- a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoverySenderEncryptedUnitTest.java
+++ b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoverySenderEncryptedUnitTest.java
@@ -1,25 +1,5 @@
package org.apache.commons.jcs3.utils.discovery;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -57,7 +37,7 @@ public class UDPDiscoverySenderEncryptedUnitTest
/** sender instance for tests */
private UDPDiscoverySender sender;
-
+
/**
* Set up the receiver. Maybe better to just code sockets here? Set up the sender for sending
@@ -73,7 +53,7 @@ public class UDPDiscoverySenderEncryptedUnitTest
EncryptingSerializer serializer = new EncryptingSerializer();
serializer.setPreSharedKey("my_key");
-
+
receiver = new UDPDiscoveryReceiver( null, null, ADDRESS, PORT );
receiver.setSerializer(serializer);
final Thread t = new Thread( receiver );
@@ -157,25 +137,21 @@ public class UDPDiscoverySenderEncryptedUnitTest
assertNotNull("message not received", msg);
assertEquals( "wrong message type", BroadcastType.REQUEST, msg.getMessageType() );
-
+
}
-
+
/**
* Wait for multicast message for 3 seconds
- *
+ *
* @return the object message or null if nothing received within 3 seconds
*/
private UDPDiscoveryMessage getMessage() {
ExecutorService executor = Executors.newCachedThreadPool();
- Callable<Object> task = new Callable<Object>() {
- public Object call() throws IOException {
- return receiver.waitForMessage();
- }
- };
+ Callable<Object> task = () -> receiver.waitForMessage();
Future<Object> future = executor.submit(task);
try {
Object obj = future.get(3, TimeUnit.SECONDS);
-
+
assertTrue( "unexpected crap received", obj instanceof UDPDiscoveryMessage );
return (UDPDiscoveryMessage) obj;
diff --git a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/serialization/CompressingSerializerUnitTest.java b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/serialization/CompressingSerializerUnitTest.java
index f9987627..1e0c209e 100644
--- a/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/serialization/CompressingSerializerUnitTest.java
+++ b/commons-jcs3-core/src/test/java/org/apache/commons/jcs3/utils/serialization/CompressingSerializerUnitTest.java
@@ -98,11 +98,12 @@ public class CompressingSerializerUnitTest
throws Exception
{
// I hate for loops.
- final String before = "adsfdsafdsafdsafdsafdsafdsafdsagfdsafdsafdssaf dsaf sadf dsaf dsaf dsaf "
- + "dsafdsa fdsaf dsaf dsafdsa dsaf dsaf dsaf dsaf dsafdsa76f dsa798f dsa6fdsa 087f "
- + "gh 987dsahb dsahbuhbfnui nufdsa hbv87 f8vhdsgbnfv h8fdg8dfjvn8fdwgj fdsgjb9fdsjbv"
- + "jvhjv hg98f-dsaghj j9fdsb gfsb 9fdshjbgb987fdsbfdwgh ujbhjbhb hbfdsgh fdshb "
- + "Ofdsgyfesgyfdsafdsafsa333 31231";
+ final String before = """
+ adsfdsafdsafdsafdsafdsafdsafdsagfdsafdsafdssaf dsaf sadf dsaf dsaf dsaf\s\
+ dsafdsa fdsaf dsaf dsafdsa dsaf dsaf dsaf dsaf dsafdsa76f dsa798f dsa6fdsa 087f\s\s\
+ gh 987dsahb dsahbuhbfnui nufdsa hbv87 f8vhdsgbnfv h8fdg8dfjvn8fdwgj fdsgjb9fdsjbv\
+ jvhjv hg98f-dsaghj j9fdsb gfsb 9fdshjbgb987fdsbfdwgh ujbhjbhb hbfdsgh fdshb\s\
+ Ofdsgyfesgyfdsafdsafsa333 31231""";
// DO WORK
final byte[] compressed = serializer.serialize( before );
diff --git a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/AnyLiteral.java b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/AnyLiteral.java
index 2371cdfb..1460bb83 100644
--- a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/AnyLiteral.java
+++ b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/AnyLiteral.java
@@ -23,6 +23,7 @@ import javax.enterprise.util.AnnotationLiteral;
public class AnyLiteral extends AnnotationLiteral<Any> implements Any
{
+ private static final long serialVersionUID = 3065708715639538185L;
public static final AnyLiteral INSTANCE = new AnyLiteral();
@Override
diff --git a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/DefaultLiteral.java b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/DefaultLiteral.java
index fbf7d5df..630f58be 100644
--- a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/DefaultLiteral.java
+++ b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/DefaultLiteral.java
@@ -23,6 +23,7 @@ import javax.enterprise.util.AnnotationLiteral;
public class DefaultLiteral extends AnnotationLiteral<Default> implements Default
{
+ private static final long serialVersionUID = -7075220723272831665L;
public static final DefaultLiteral INSTANCE = new DefaultLiteral();
@Override
diff --git a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/ExtraJCacheExtension.java b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/ExtraJCacheExtension.java
index 8acf0927..97ac289f 100644
--- a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/ExtraJCacheExtension.java
+++ b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/cdi/ExtraJCacheExtension.java
@@ -41,12 +41,7 @@ public class ExtraJCacheExtension implements Extension
public <A> void processBean(final @Observes ProcessBean<A> processBeanEvent)
{
- if (!ACTIVATED)
- {
- return;
- }
-
- if (cacheManagerFound && cacheProviderFound)
+ if (!ACTIVATED || (cacheManagerFound && cacheProviderFound))
{
return;
}
@@ -69,12 +64,7 @@ public class ExtraJCacheExtension implements Extension
public void addJCacheBeans(final @Observes AfterBeanDiscovery afterBeanDiscovery)
{
- if (!ACTIVATED)
- {
- return;
- }
-
- if (cacheManagerFound && cacheProviderFound) {
+ if (!ACTIVATED || (cacheManagerFound && cacheProviderFound)) {
return;
}
diff --git a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/loader/CacheLoaderAdapter.java b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/loader/CacheLoaderAdapter.java
index 24dea7cd..51c601f0 100644
--- a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/loader/CacheLoaderAdapter.java
+++ b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/loader/CacheLoaderAdapter.java
@@ -26,6 +26,8 @@ import java.util.Map;
public abstract class CacheLoaderAdapter<K, V> implements CacheLoader<K, V>, Factory<CacheLoader<K, V>>
{
+ private static final long serialVersionUID = -2683385801194322067L;
+
@Override
public Map<K, V> loadAll(final Iterable<? extends K> keys) throws CacheLoaderException
{
diff --git a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/loader/CompositeCacheLoader.java b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/loader/CompositeCacheLoader.java
index 254b4177..19c2f13e 100644
--- a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/loader/CompositeCacheLoader.java
+++ b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/loader/CompositeCacheLoader.java
@@ -33,6 +33,7 @@ import java.util.Map;
public class CompositeCacheLoader<K, V> implements CacheLoader<K, V>, Closeable, Factory<CacheLoader<K, V>>
{
+ private static final long serialVersionUID = 5636608842581992435L;
private final CacheLoader<K, V>[] delegates;
public CompositeCacheLoader(final CacheLoader<K, V>... delegates)
diff --git a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/web/InMemoryResponse.java b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/web/InMemoryResponse.java
index f2025024..c507b3e4 100644
--- a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/web/InMemoryResponse.java
+++ b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/web/InMemoryResponse.java
@@ -38,6 +38,8 @@ import javax.servlet.http.HttpServletResponseWrapper;
public class InMemoryResponse extends HttpServletResponseWrapper implements Serializable
{
+ private static final long serialVersionUID = 6827502171557661881L;
+
private final OutputStream buffer;
private final Collection<Cookie> cookies = new CopyOnWriteArraySet<>();
@@ -215,7 +217,7 @@ public class InMemoryResponse extends HttpServletResponseWrapper implements Seri
@Override
public void setWriteListener(WriteListener writeListener) {
// TODO Auto-generated method stub
-
+
}
};
}
diff --git a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/web/JCacheFilter.java b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/web/JCacheFilter.java
index 540a8760..264740cb 100644
--- a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/web/JCacheFilter.java
+++ b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/web/JCacheFilter.java
@@ -39,9 +39,6 @@ import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.cache.configuration.FactoryBuilder;
import javax.cache.configuration.MutableConfiguration;
-import javax.cache.expiry.ExpiryPolicy;
-import javax.cache.integration.CacheLoader;
-import javax.cache.integration.CacheWriter;
import javax.cache.spi.CachingProvider;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -95,16 +92,16 @@ public class JCacheFilter implements Filter
configuration.setWriteThrough("true".equals(properties.getProperty("write-through", "false")));
if (configuration.isReadThrough())
{
- configuration.setCacheLoaderFactory(new FactoryBuilder.ClassFactory<CacheLoader<PageKey, Page>>(properties.getProperty("cache-loader-factory")));
+ configuration.setCacheLoaderFactory(new FactoryBuilder.ClassFactory<>(properties.getProperty("cache-loader-factory")));
}
if (configuration.isWriteThrough())
{
- configuration.setCacheWriterFactory(new FactoryBuilder.ClassFactory<CacheWriter<? super PageKey, ? super Page>>(properties.getProperty("cache-writer-factory")));
+ configuration.setCacheWriterFactory(new FactoryBuilder.ClassFactory<>(properties.getProperty("cache-writer-factory")));
}
final String expiryPolicy = properties.getProperty("expiry-policy-factory");
if (expiryPolicy != null)
{
- configuration.setExpiryPolicyFactory(new FactoryBuilder.ClassFactory<ExpiryPolicy>(expiryPolicy));
+ configuration.setExpiryPolicyFactory(new FactoryBuilder.ClassFactory<>(expiryPolicy));
}
configuration.setManagementEnabled("true".equals(properties.getProperty("management-enabled", "false")));
configuration.setStatisticsEnabled("true".equals(properties.getProperty("statistics-enabled", "false")));
@@ -244,6 +241,7 @@ public class JCacheFilter implements Filter
}
protected static class PageKey implements Serializable {
+ private static final long serialVersionUID = 3401480765010789184L;
private final String uri;
private boolean gzip;
@@ -285,6 +283,7 @@ public class JCacheFilter implements Filter
}
protected static class Page implements Serializable {
+ private static final long serialVersionUID = 76822335849713095L;
private final int status;
private final String contentType;
private final int contentLength;
diff --git a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/AsyncCacheWriter.java b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/AsyncCacheWriter.java
index 0abc65b8..3768b393 100644
--- a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/AsyncCacheWriter.java
+++ b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/AsyncCacheWriter.java
@@ -35,6 +35,8 @@ import java.util.logging.Logger;
public class AsyncCacheWriter<K, V> implements CacheWriter<K, V>, Closeable, Factory<CacheWriter<K, V>>
{
+ private static final long serialVersionUID = 4135226004268295465L;
+
private static final Logger LOGGER = Logger.getLogger(AsyncCacheWriter.class.getName());
private final CacheWriter<K, V> writer;
diff --git a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/CacheWriterAdapter.java b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/CacheWriterAdapter.java
index cbcd3e54..10418c75 100644
--- a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/CacheWriterAdapter.java
+++ b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/CacheWriterAdapter.java
@@ -26,6 +26,8 @@ import java.util.Collection;
public abstract class CacheWriterAdapter<K, V> implements CacheWriter<K, V>, Factory<CacheWriter<K, V>>
{
+ private static final long serialVersionUID = -2784825625311754333L;
+
@Override
public void writeAll(final Collection<Cache.Entry<? extends K, ? extends V>> entries) throws CacheWriterException
{
diff --git a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/CompositeCacheWriter.java b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/CompositeCacheWriter.java
index 3fad8416..477c25c5 100644
--- a/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/CompositeCacheWriter.java
+++ b/commons-jcs3-jcache-extras/src/main/java/org/apache/commons/jcs3/jcache/extras/writer/CompositeCacheWriter.java
@@ -31,6 +31,7 @@ import java.util.Collection;
public class CompositeCacheWriter<K, V> implements CacheWriter<K, V>, Closeable, Factory<CacheWriter<K, V>>
{
+ private static final long serialVersionUID = -3305787850424123811L;
private final CacheWriter<K, V>[] writers;
public CompositeCacheWriter(final CacheWriter<K, V>... writers)
diff --git a/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/loader/CacheLoaderAdapterTest.java b/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/loader/CacheLoaderAdapterTest.java
index 9a11f7b0..6757778b 100644
--- a/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/loader/CacheLoaderAdapterTest.java
+++ b/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/loader/CacheLoaderAdapterTest.java
@@ -41,6 +41,8 @@ public class CacheLoaderAdapterTest
private final AtomicInteger count = new AtomicInteger(0);
private final Configuration<?, ?> config = new MutableConfiguration<String, String>().setStoreByValue(false).setReadThrough(true).setCacheLoaderFactory(new CacheLoaderAdapter<String, String>()
{
+ private static final long serialVersionUID = 5824701188219321027L;
+
@Override
public String load(final String key) throws CacheLoaderException
{
diff --git a/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/loader/CompositeCacheLoaderTest.java b/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/loader/CompositeCacheLoaderTest.java
index f743df2d..529f50dc 100644
--- a/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/loader/CompositeCacheLoaderTest.java
+++ b/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/loader/CompositeCacheLoaderTest.java
@@ -37,8 +37,10 @@ public class CompositeCacheLoaderTest
private final AtomicInteger count = new AtomicInteger(0);
- private final CacheLoaderAdapter<String, String> loader1 = new CacheLoaderAdapter<String, String>()
+ private final CacheLoaderAdapter<String, String> loader1 = new CacheLoaderAdapter<>()
{
+ private static final long serialVersionUID = 4115224634848656083L;
+
@Override
public String load(final String key) throws CacheLoaderException
{
@@ -46,8 +48,10 @@ public class CompositeCacheLoaderTest
return null;
}
};
- private final CacheLoaderAdapter<String, String> loader2 = new CacheLoaderAdapter<String, String>()
+ private final CacheLoaderAdapter<String, String> loader2 = new CacheLoaderAdapter<>()
{
+ private static final long serialVersionUID = 6521646710056500743L;
+
@Override
public String load(final String key) throws CacheLoaderException
{
diff --git a/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/writer/CacheWriterAdapterTest.java b/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/writer/CacheWriterAdapterTest.java
index 68b440c8..0476a888 100644
--- a/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/writer/CacheWriterAdapterTest.java
+++ b/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/writer/CacheWriterAdapterTest.java
@@ -45,6 +45,8 @@ public class CacheWriterAdapterTest
.setStoreByValue(false).setReadThrough(true)
.setCacheWriterFactory(new CacheWriterAdapter<String, String>()
{
+ private static final long serialVersionUID = 124351798952737984L;
+
@Override
public void write(final Cache.Entry<? extends String, ? extends String> entry) throws CacheWriterException
{
@@ -69,7 +71,9 @@ public class CacheWriterAdapterTest
cache.remove("foo");
assertTrue(copy.isEmpty());
- cache.putAll(new HashMap<String, String>() {{
+ cache.putAll(new HashMap<String, String>() {private static final long serialVersionUID = -5341092848989593322L;
+
+ {
put("a", "b");
put("b", "c");
}});
diff --git a/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/writer/CompositeCacheWriterTest.java b/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/writer/CompositeCacheWriterTest.java
index 04004d07..00073f88 100644
--- a/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/writer/CompositeCacheWriterTest.java
+++ b/commons-jcs3-jcache-extras/src/test/java/org/apache/commons/jcs3/jcache/extras/writer/CompositeCacheWriterTest.java
@@ -41,8 +41,10 @@ public class CompositeCacheWriterTest
private final Map<String, String> copy1 = new HashMap<>();
private final Map<String, String> copy2 = new HashMap<>();
- private final CacheWriterAdapter<String, String> writer1 = new CacheWriterAdapter<String, String>()
+ private final CacheWriterAdapter<String, String> writer1 = new CacheWriterAdapter<>()
{
+ private static final long serialVersionUID = -5802177697962311794L;
+
@Override
public void write(final Cache.Entry<? extends String, ? extends String> entry) throws CacheWriterException
{
@@ -55,8 +57,10 @@ public class CompositeCacheWriterTest
copy1.remove(key);
}
};
- private final CacheWriterAdapter<String, String> writer2 = new CacheWriterAdapter<String, String>()
+ private final CacheWriterAdapter<String, String> writer2 = new CacheWriterAdapter<>()
{
+ private static final long serialVersionUID = 3495295030098159027L;
+
@Override
public void write(final Cache.Entry<? extends String, ? extends String> entry) throws CacheWriterException
{
diff --git a/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCache.java b/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCache.java
index 41959e49..618e6288 100644
--- a/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCache.java
+++ b/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCache.java
@@ -30,6 +30,8 @@ import java.util.concurrent.locks.ReentrantLock;
public class OpenJPAJCacheDataCache extends AbstractDataCache
{
+ private static final long serialVersionUID = -5472249582181438434L;
+
private static final String OPENJPA_PREFIX = "openjpa.datacache.";
private final Lock lock = new ReentrantLock();
diff --git a/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCacheManager.java b/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCacheManager.java
index 9bc66667..d1247706 100644
--- a/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCacheManager.java
+++ b/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCacheManager.java
@@ -18,9 +18,9 @@
*/
package org.apache.commons.jcs3.jcache.openjpa;
-import org.apache.openjpa.conf.OpenJPAConfiguration;
-import org.apache.openjpa.datacache.DataCacheManagerImpl;
-import org.apache.openjpa.lib.conf.ObjectValue;
+import java.net.URI;
+import java.util.Map;
+import java.util.Properties;
import javax.cache.Cache;
import javax.cache.CacheManager;
@@ -29,13 +29,11 @@ import javax.cache.configuration.FactoryBuilder;
import javax.cache.configuration.MutableConfiguration;
import javax.cache.expiry.CreatedExpiryPolicy;
import javax.cache.expiry.Duration;
-import javax.cache.expiry.ExpiryPolicy;
-import javax.cache.integration.CacheLoader;
-import javax.cache.integration.CacheWriter;
import javax.cache.spi.CachingProvider;
-import java.net.URI;
-import java.util.Map;
-import java.util.Properties;
+
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.datacache.DataCacheManagerImpl;
+import org.apache.openjpa.lib.conf.ObjectValue;
public class OpenJPAJCacheDataCacheManager extends DataCacheManagerImpl
{
@@ -90,20 +88,20 @@ public class OpenJPAJCacheDataCacheManager extends DataCacheManagerImpl
configuration.setWriteThrough("true".equals(properties.getProperty("jcache.write-through", "false")));
if (configuration.isReadThrough())
{
- configuration.setCacheLoaderFactory(new FactoryBuilder.ClassFactory<CacheLoader<Object, Object>>(properties.getProperty("jcache.cache-loader-factory")));
+ configuration.setCacheLoaderFactory(new FactoryBuilder.ClassFactory<>(properties.getProperty("jcache.cache-loader-factory")));
}
if (configuration.isWriteThrough())
{
- configuration.setCacheWriterFactory(new FactoryBuilder.ClassFactory<CacheWriter<Object, Object>>(properties.getProperty("jcache.cache-writer-factory")));
+ configuration.setCacheWriterFactory(new FactoryBuilder.ClassFactory<>(properties.getProperty("jcache.cache-writer-factory")));
}
final String expirtyPolicy = properties.getProperty("jcache.expiry-policy-factory");
if (expirtyPolicy != null)
{
- configuration.setExpiryPolicyFactory(new FactoryBuilder.ClassFactory<ExpiryPolicy>(expirtyPolicy));
+ configuration.setExpiryPolicyFactory(new FactoryBuilder.ClassFactory<>(expirtyPolicy));
}
else
{
- configuration.setExpiryPolicyFactory(new FactoryBuilder.SingletonFactory<ExpiryPolicy>(new CreatedExpiryPolicy(Duration.FIVE_MINUTES)));
+ configuration.setExpiryPolicyFactory(new FactoryBuilder.SingletonFactory<>(new CreatedExpiryPolicy(Duration.FIVE_MINUTES)));
}
configuration.setManagementEnabled("true".equals(properties.getProperty("jcache.management-enabled", "false")));
configuration.setStatisticsEnabled("true".equals(properties.getProperty("jcache.statistics-enabled", "false")));
diff --git a/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheQueryCache.java b/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheQueryCache.java
index 559941e4..0f4834fb 100644
--- a/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheQueryCache.java
+++ b/commons-jcs3-jcache-openjpa/src/main/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheQueryCache.java
@@ -32,6 +32,7 @@ import java.util.concurrent.locks.ReentrantLock;
public class OpenJPAJCacheQueryCache extends AbstractQueryCache
{
+ private static final long serialVersionUID = 6646905946950592841L;
private static final String OPENJPA_PREFIX = "openjpa.querycache.";
private static final String QUERY_CACHE_NAME = "query";
diff --git a/commons-jcs3-jcache-openjpa/src/test/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCacheTest.java b/commons-jcs3-jcache-openjpa/src/test/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCacheTest.java
index c1104eda..091ec9b1 100644
--- a/commons-jcs3-jcache-openjpa/src/test/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCacheTest.java
+++ b/commons-jcs3-jcache-openjpa/src/test/java/org/apache/commons/jcs3/jcache/openjpa/OpenJPAJCacheDataCacheTest.java
@@ -45,7 +45,9 @@ import org.junit.Test;
public class OpenJPAJCacheDataCacheTest
{
private static final Properties props = new Properties()
- {{
+ {private static final long serialVersionUID = 498881935058549341L;
+
+ {
setProperty("openjpa.MetaDataFactory", "jpa(Types=" + MyEntity.class.getName() + ")");
setProperty("openjpa.ConnectionDriverName", EmbeddedDriver.class.getName());
setProperty("openjpa.ConnectionURL", "jdbc:derby:memory:test;create=true");
diff --git a/commons-jcs3-jcache-tck/src/test/java/org/apache/commons/jcs3/jcache/EnsureCDIIsTestedWhenTCKsRunTest.java b/commons-jcs3-jcache-tck/src/test/java/org/apache/commons/jcs3/jcache/EnsureCDIIsTestedWhenTCKsRunTest.java
index e6063b0d..2867b28f 100644
--- a/commons-jcs3-jcache-tck/src/test/java/org/apache/commons/jcs3/jcache/EnsureCDIIsTestedWhenTCKsRunTest.java
+++ b/commons-jcs3-jcache-tck/src/test/java/org/apache/commons/jcs3/jcache/EnsureCDIIsTestedWhenTCKsRunTest.java
@@ -18,15 +18,16 @@
*/
package org.apache.commons.jcs3.jcache;
-import org.junit.Test;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertTrue;
-import javax.cache.annotation.BeanProvider;
import java.util.Iterator;
import java.util.ServiceLoader;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import javax.cache.annotation.BeanProvider;
+
+import org.junit.Test;
// useless test but without it we are not sure
// CDI TCKs passed
diff --git a/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCache.java b/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCache.java
index b0541e74..4a3c81ae 100644
--- a/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCache.java
+++ b/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCache.java
@@ -201,7 +201,7 @@ public class JCSCache<K, V> implements Cache<K, V>
return doGetControllingExpiry(getStart, key, true, false, false, true);
}
- private V doLoad(final K key, final boolean update, final long now, final boolean propagateLoadException)
+ private V doLoad(final K key, final boolean update, final boolean propagateLoadException)
{
V v = null;
try
@@ -291,7 +291,7 @@ public class JCSCache<K, V> implements Cache<K, V>
V val = elt != null ? elt.getVal() : null;
if (val == null && config.isReadThrough())
{
- val = doLoad(key, false, now, false);
+ val = doLoad(key, false, false);
if (val != null)
{
result.put(key, val);
@@ -528,7 +528,7 @@ public class JCSCache<K, V> implements Cache<K, V>
{
if (!skipLoad)
{
- v = doLoad(key, false, getStart, propagateLoadException);
+ v = doLoad(key, false, propagateLoadException);
}
}
else if (statisticsEnabled)
@@ -587,7 +587,7 @@ public class JCSCache<K, V> implements Cache<K, V>
}
if (value == null && config.isReadThrough())
{
- value = doLoad(key, false, Times.now(false), false);
+ value = doLoad(key, false, false);
}
if (value != null && value.equals(oldValue))
{
@@ -655,7 +655,7 @@ public class JCSCache<K, V> implements Cache<K, V>
V oldValue = elt.getVal();
if (oldValue == null && config.isReadThrough())
{
- oldValue = doLoad(key, false, Times.now(false), false);
+ oldValue = doLoad(key, false, false);
}
else if (statisticsEnabled)
{
@@ -734,7 +734,7 @@ public class JCSCache<K, V> implements Cache<K, V>
{
if (replaceExistingValues)
{
- doLoad(k, containsKey(k), now, completionListener != null);
+ doLoad(k, containsKey(k), completionListener != null);
continue;
}
if (containsKey(k))
@@ -853,7 +853,7 @@ public class JCSCache<K, V> implements Cache<K, V>
{
assertNotClosed();
final Iterator<K> keys = new HashSet<>(delegate.getKeySet()).iterator();
- return new Iterator<Entry<K, V>>()
+ return new Iterator<>()
{
private K lastKey;
diff --git a/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCachingManager.java b/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCachingManager.java
index 3d4706e8..eca680b4 100644
--- a/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCachingManager.java
+++ b/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCachingManager.java
@@ -49,20 +49,22 @@ public class JCSCachingManager implements CacheManager
{
private static final Subsitutor SUBSTITUTOR = Subsitutor.Helper.INSTANCE;
private static final String DEFAULT_CONFIG =
- "jcs.default=DC\n" +
- "jcs.default.cacheattributes=org.apache.commons.jcs3.engine.CompositeCacheAttributes\n" +
- "jcs.default.cacheattributes.MaxObjects=200001\n" +
- "jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs3.engine.memory.lru.LRUMemoryCache\n" +
- "jcs.default.cacheattributes.UseMemoryShrinker=true\n" +
- "jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600\n" +
- "jcs.default.cacheattributes.ShrinkerIntervalSeconds=60\n" +
- "jcs.default.elementattributes=org.apache.commons.jcs3.engine.ElementAttributes\n" +
- "jcs.default.elementattributes.IsEternal=false\n" +
- "jcs.default.elementattributes.MaxLife=700\n" +
- "jcs.default.elementattributes.IdleTime=1800\n" +
- "jcs.default.elementattributes.IsSpool=true\n" +
- "jcs.default.elementattributes.IsRemote=true\n" +
- "jcs.default.elementattributes.IsLateral=true\n";
+ """
+ jcs.default=DC
+ jcs.default.cacheattributes=org.apache.commons.jcs3.engine.CompositeCacheAttributes
+ jcs.default.cacheattributes.MaxObjects=200001
+ jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs3.engine.memory.lru.LRUMemoryCache
+ jcs.default.cacheattributes.UseMemoryShrinker=true
+ jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+ jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+ jcs.default.elementattributes=org.apache.commons.jcs3.engine.ElementAttributes
+ jcs.default.elementattributes.IsEternal=false
+ jcs.default.elementattributes.MaxLife=700
+ jcs.default.elementattributes.IdleTime=1800
+ jcs.default.elementattributes.IsSpool=true
+ jcs.default.elementattributes.IsRemote=true
+ jcs.default.elementattributes.IsLateral=true
+ """;
private static class InternalManager extends CompositeCacheManager
{
@@ -198,7 +200,7 @@ public class JCSCachingManager implements CacheManager
final Cache<K, V> cache = ClassLoaderAwareCache.wrap(loader,
new JCSCache<>(
loader, this, cacheName,
- new JCSConfiguration<K, V>(configuration, keyType, valueType),
+ new JCSConfiguration<>(configuration, keyType, valueType),
properties,
ExpiryAwareCache.class.cast(delegate.getCache(cacheName))));
caches.putIfAbsent(cacheName, cache);
diff --git a/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheInvocationContextImpl.java b/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheInvocationContextImpl.java
index 74f37ba7..e20c22e0 100644
--- a/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheInvocationContextImpl.java
+++ b/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheInvocationContextImpl.java
@@ -28,7 +28,7 @@ import javax.interceptor.InvocationContext;
public class CacheInvocationContextImpl<A extends Annotation> extends CacheMethodDetailsImpl<A> implements CacheInvocationContext<A>
{
- private static final Object[] EMPTY_ARGS = new Object[0];
+ private static final Object[] EMPTY_ARGS = {};
private CacheInvocationParameter[] parameters;
diff --git a/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/jmx/ConfigurableMBeanServerIdBuilder.java b/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/jmx/ConfigurableMBeanServerIdBuilder.java
index 29660d6c..38e3adb2 100644
--- a/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/jmx/ConfigurableMBeanServerIdBuilder.java
+++ b/commons-jcs3-jcache/src/main/java/org/apache/commons/jcs3/jcache/jmx/ConfigurableMBeanServerIdBuilder.java
@@ -86,7 +86,7 @@ public class ConfigurableMBeanServerIdBuilder extends MBeanServerBuilder
return server;
}
- private class ForceIdMBeanServerDelegate extends MBeanServerDelegate
+ private static class ForceIdMBeanServerDelegate extends MBeanServerDelegate
{
private final MBeanServerDelegate delegate;
diff --git a/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/CacheTest.java b/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/CacheTest.java
index 04bad92f..e44c5ade 100644
--- a/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/CacheTest.java
+++ b/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/CacheTest.java
@@ -91,7 +91,7 @@ public class CacheTest
{
final CachingProvider cachingProvider = Caching.getCachingProvider();
final CacheManager cacheManager = cachingProvider.getCacheManager();
- final Cache<String, String> cache = cacheManager.createCache("default", new MutableConfiguration<String, String>());
+ final Cache<String, String> cache = cacheManager.createCache("default", new MutableConfiguration<>());
assertFalse(cache.containsKey("foo"));
cache.put("foo", "bar");
assertTrue(cache.containsKey("foo"));
@@ -263,7 +263,7 @@ public class CacheTest
@Override
public Factory<CacheLoader<Object, Object>> getCacheLoaderFactory()
{
- return () -> new CacheLoader<Object, Object>()
+ return () -> new CacheLoader<>()
{
@Override
public Object load(final Object key) throws CacheLoaderException
diff --git a/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/ExpiryListenerTest.java b/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/ExpiryListenerTest.java
index 901efdf0..a065e26b 100644
--- a/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/ExpiryListenerTest.java
+++ b/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/ExpiryListenerTest.java
@@ -38,7 +38,6 @@ import javax.cache.event.CacheEntryExpiredListener;
import javax.cache.event.CacheEntryListenerException;
import javax.cache.expiry.CreatedExpiryPolicy;
import javax.cache.expiry.Duration;
-import javax.cache.expiry.ExpiryPolicy;
import javax.cache.spi.CachingProvider;
import org.junit.Test;
@@ -51,7 +50,7 @@ public class ExpiryListenerTest {
final CacheManager cacheManager = cachingProvider.getCacheManager();
final CacheEntryExpiredListenerImpl listener = new CacheEntryExpiredListenerImpl();
cacheManager.createCache("default", new MutableConfiguration<String, String>()
- .setExpiryPolicyFactory(new FactoryBuilder.SingletonFactory<ExpiryPolicy>(
+ .setExpiryPolicyFactory(new FactoryBuilder.SingletonFactory<>(
new CreatedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, 1))))
.addCacheEntryListenerConfiguration(new MutableCacheEntryListenerConfiguration<>(
FactoryBuilder.factoryOf(listener),
diff --git a/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/ImmediateExpiryTest.java b/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/ImmediateExpiryTest.java
index a3b372bc..ea5f6384 100644
--- a/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/ImmediateExpiryTest.java
+++ b/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/ImmediateExpiryTest.java
@@ -19,7 +19,7 @@
package org.apache.commons.jcs3.jcache;
-import org.junit.Test;
+import static org.junit.Assert.assertFalse;
import javax.cache.Cache;
import javax.cache.CacheManager;
@@ -28,10 +28,9 @@ import javax.cache.configuration.FactoryBuilder;
import javax.cache.configuration.MutableConfiguration;
import javax.cache.expiry.CreatedExpiryPolicy;
import javax.cache.expiry.Duration;
-import javax.cache.expiry.ExpiryPolicy;
import javax.cache.spi.CachingProvider;
-import static org.junit.Assert.assertFalse;
+import org.junit.Test;
public class ImmediateExpiryTest
{
@@ -43,7 +42,7 @@ public class ImmediateExpiryTest
cacheManager.createCache("default",
new MutableConfiguration<>()
.setExpiryPolicyFactory(
- new FactoryBuilder.SingletonFactory<ExpiryPolicy>(new CreatedExpiryPolicy(Duration.ZERO))));
+ new FactoryBuilder.SingletonFactory<>(new CreatedExpiryPolicy(Duration.ZERO))));
final Cache<String, String> cache = cacheManager.getCache("default");
assertFalse(cache.containsKey("foo"));
cache.put("foo", "bar");
diff --git a/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/cdi/CDIJCacheHelperTest.java b/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/cdi/CDIJCacheHelperTest.java
index b7992d3a..16c550d8 100644
--- a/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/cdi/CDIJCacheHelperTest.java
+++ b/commons-jcs3-jcache/src/test/java/org/apache/commons/jcs3/jcache/cdi/CDIJCacheHelperTest.java
@@ -70,6 +70,7 @@ public class CDIJCacheHelperTest
}
}
+ @Override
public Constructor<?> getConstructor()
{
return null;