You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/07/10 01:23:07 UTC
(commons-jcs) 05/31: Use final
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit 6bbacd5cfc61820912967bd6722366b88eded788
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jul 9 19:27:03 2024 -0400
Use final
---
.../remote/AbstractRemoteAuxiliaryCache.java | 2 +-
.../engine/control/CompositeCacheConfigurator.java | 6 ++---
.../utils/serialization/CompressingSerializer.java | 2 +-
.../jcs/yajcache/beans/CacheChangeEvent.java | 2 +-
.../jcs/yajcache/beans/CacheChangeSupport.java | 28 ++++++++++------------
.../jcs/yajcache/beans/CacheClearEvent.java | 4 ++--
.../jcs/yajcache/beans/CachePutBeanCloneEvent.java | 6 ++---
.../jcs/yajcache/beans/CachePutBeanCopyEvent.java | 6 ++---
.../jcs/yajcache/beans/CachePutCopyEvent.java | 6 ++---
.../jcs/yajcache/beans/CacheRemoveEvent.java | 6 ++---
.../commons/jcs/yajcache/core/CacheEntry.java | 9 ++++---
.../jcs/yajcache/file/CacheFileContent.java | 26 ++++++++++----------
.../commons/jcs/yajcache/util/ClassUtils.java | 4 ++--
.../jcs/yajcache/core/CacheManagerTest.java | 22 ++++++++---------
14 files changed, 64 insertions(+), 65 deletions(-)
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java
index 4eda684a..ef535281 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java
@@ -578,7 +578,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
// convert so we don't have to know about the object on the
// other end.
- ICacheElementSerialized<K, V> serialized = SerializationConversionUtil.getSerializedCacheElement( ce, super.getElementSerializer() );
+ final ICacheElementSerialized<K, V> serialized = SerializationConversionUtil.getSerializedCacheElement( ce, super.getElementSerializer() );
remoteCacheService.update( serialized, getListenerId() );
}
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheConfigurator.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheConfigurator.java
index 93d1a874..34786181 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheConfigurator.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheConfigurator.java
@@ -422,7 +422,7 @@ public class CompositeCacheConfigurator
log.debug( "Parsing region name \"{0}\", value \"{1}\"", regName, auxiliaries );
- String[] auxNames = auxiliaries.split("\\s*,\\s*");
+ final String[] auxNames = auxiliaries.split("\\s*,\\s*");
// just to be on the safe side...
if (auxNames.length == 0)
@@ -430,7 +430,7 @@ public class CompositeCacheConfigurator
return null;
}
- for (String auxName : auxNames)
+ for (final String auxName : auxNames)
{
if (auxName.isEmpty())
{
@@ -440,7 +440,7 @@ public class CompositeCacheConfigurator
log.debug( "Parsing auxiliary named \"{0}\".", auxName );
- AuxiliaryCache<K, V> auxCache = parseAuxiliary( props, ccm, auxName, regName );
+ final AuxiliaryCache<K, V> auxCache = parseAuxiliary( props, ccm, auxName, regName );
if ( auxCache != null )
{
diff --git a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/utils/serialization/CompressingSerializer.java b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/utils/serialization/CompressingSerializer.java
index a689f527..1c1cdb13 100644
--- a/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/utils/serialization/CompressingSerializer.java
+++ b/commons-jcs3-core/src/main/java/org/apache/commons/jcs3/utils/serialization/CompressingSerializer.java
@@ -46,7 +46,7 @@ public class CompressingSerializer extends StandardSerializer
* @param serializer the wrapped serializer
* @since 3.1
*/
- public CompressingSerializer(IElementSerializer serializer)
+ public CompressingSerializer(final IElementSerializer serializer)
{
this.serializer = serializer;
}
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheChangeEvent.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheChangeEvent.java
index 64444784..4cd807cc 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheChangeEvent.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheChangeEvent.java
@@ -26,7 +26,7 @@ import org.apache.commons.jcs.yajcache.lang.annotation.*;
@CopyRightApache
public abstract class CacheChangeEvent<V> extends java.util.EventObject {
/** Creates a new instance of CacheEvent */
- protected CacheChangeEvent(@NonNullable ICache<V> cache) {
+ protected CacheChangeEvent(@NonNullable final ICache<V> cache) {
super(cache);
}
/** Returns the cache which is the source of the events. */
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheChangeSupport.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheChangeSupport.java
index df078787..90820ad2 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheChangeSupport.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheChangeSupport.java
@@ -19,10 +19,6 @@ package org.apache.commons.jcs.yajcache.beans;
* under the License.
*/
-import org.apache.commons.jcs.yajcache.beans.CacheChangeEvent;
-import org.apache.commons.jcs.yajcache.beans.CacheClearEvent;
-import org.apache.commons.jcs.yajcache.beans.CachePutEvent;
-import org.apache.commons.jcs.yajcache.beans.CacheRemoveEvent;
import org.apache.commons.jcs.yajcache.core.ICache;
import org.apache.commons.jcs.yajcache.lang.annotation.*;
@@ -34,18 +30,18 @@ import java.util.concurrent.CopyOnWriteArrayList;
@CopyRightApache
public class CacheChangeSupport<V> {
private final @NonNullable List<ICacheChangeListener<V>> listeners
- = new CopyOnWriteArrayList<ICacheChangeListener<V>>();
+ = new CopyOnWriteArrayList<>();
- private ICache<V> cache;
+ private final ICache<V> cache;
- public CacheChangeSupport(@NonNullable ICache<V> cache) {
+ public CacheChangeSupport(@NonNullable final ICache<V> cache) {
this.cache = cache;
}
- public void addCacheChangeListener(@NonNullable ICacheChangeListener<V> listener)
+ public void addCacheChangeListener(@NonNullable final ICacheChangeListener<V> listener)
{
listeners.add(listener);
}
- public void removeCacheChangeListener(@NonNullable ICacheChangeListener<V> listener)
+ public void removeCacheChangeListener(@NonNullable final ICacheChangeListener<V> listener)
{
listeners.remove(listener);
}
@@ -53,22 +49,22 @@ public class CacheChangeSupport<V> {
{
return listeners;
}
- public void fireCacheChange(@NonNullable CacheChangeEvent<V> evt)
+ public void fireCacheChange(@NonNullable final CacheChangeEvent<V> evt)
{
- for (ICacheChangeListener<V> listener : this.listeners) {
+ for (final ICacheChangeListener<V> listener : this.listeners) {
listener.cacheChange(evt);
}
}
- public void fireCachePut(@NonNullable String key, @NonNullable V value)
+ public void fireCachePut(@NonNullable final String key, @NonNullable final V value)
{
- this.fireCacheChange(new CachePutEvent<V>(this.cache, key, value));
+ this.fireCacheChange(new CachePutEvent<>(this.cache, key, value));
}
- public void fireCacheRemove(@NonNullable String key)
+ public void fireCacheRemove(@NonNullable final String key)
{
- this.fireCacheChange(new CacheRemoveEvent<V>(this.cache, key));
+ this.fireCacheChange(new CacheRemoveEvent<>(this.cache, key));
}
public void fireCacheClear()
{
- this.fireCacheChange(new CacheClearEvent<V>(this.cache));
+ this.fireCacheChange(new CacheClearEvent<>(this.cache));
}
}
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheClearEvent.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheClearEvent.java
index 318665eb..93800201 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheClearEvent.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheClearEvent.java
@@ -25,12 +25,12 @@ import org.apache.commons.jcs.yajcache.lang.annotation.*;
*/
@CopyRightApache
public class CacheClearEvent<V> extends CacheChangeEvent<V> {
- public CacheClearEvent(@NonNullable ICache<V> cache)
+ public CacheClearEvent(@NonNullable final ICache<V> cache)
{
super(cache);
}
@Override
- public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
+ public boolean dispatch(@NonNullable final ICacheChangeHandler<V> handler) {
return handler.handleClear(super.getCache().getName());
}
}
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutBeanCloneEvent.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutBeanCloneEvent.java
index fadae9e2..f0ecf9bb 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutBeanCloneEvent.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutBeanCloneEvent.java
@@ -25,13 +25,13 @@ import org.apache.commons.jcs.yajcache.lang.annotation.*;
*/
@CopyRightApache
public class CachePutBeanCloneEvent<V> extends CachePutEvent<V> {
- protected CachePutBeanCloneEvent(@NonNullable ICache<V> cache,
- @NonNullable String key, @NonNullable V val)
+ protected CachePutBeanCloneEvent(@NonNullable final ICache<V> cache,
+ @NonNullable final String key, @NonNullable final V val)
{
super(cache, key, val);
}
@Override
- public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
+ public boolean dispatch(@NonNullable final ICacheChangeHandler<V> handler) {
return handler.handlePutBeanClone(
super.getCache().getName(), super.getKey(), super.getValue());
}
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutBeanCopyEvent.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutBeanCopyEvent.java
index 92239172..c132d83d 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutBeanCopyEvent.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutBeanCopyEvent.java
@@ -25,13 +25,13 @@ import org.apache.commons.jcs.yajcache.lang.annotation.*;
*/
@CopyRightApache
public class CachePutBeanCopyEvent<V> extends CachePutEvent<V> {
- public CachePutBeanCopyEvent(@NonNullable ICache<V> cache,
- @NonNullable String key, @NonNullable V val)
+ public CachePutBeanCopyEvent(@NonNullable final ICache<V> cache,
+ @NonNullable final String key, @NonNullable final V val)
{
super(cache, key, val);
}
@Override
- public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
+ public boolean dispatch(@NonNullable final ICacheChangeHandler<V> handler) {
return handler.handlePutBeanCopy(
super.getCache().getName(), super.getKey(), super.getValue());
}
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutCopyEvent.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutCopyEvent.java
index f0897eee..2a8ad27c 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutCopyEvent.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CachePutCopyEvent.java
@@ -25,13 +25,13 @@ import org.apache.commons.jcs.yajcache.lang.annotation.*;
*/
@CopyRightApache
public class CachePutCopyEvent<V> extends CachePutEvent<V> {
- public CachePutCopyEvent(@NonNullable ICache<V> cache,
- @NonNullable String key, @NonNullable V val)
+ public CachePutCopyEvent(@NonNullable final ICache<V> cache,
+ @NonNullable final String key, @NonNullable final V val)
{
super(cache, key, val);
}
@Override
- public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
+ public boolean dispatch(@NonNullable final ICacheChangeHandler<V> handler) {
return handler.handlePutCopy(
super.getCache().getName(), super.getKey(), super.getValue());
}
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheRemoveEvent.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheRemoveEvent.java
index 5c3b1387..127a3b7d 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheRemoveEvent.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/beans/CacheRemoveEvent.java
@@ -27,8 +27,8 @@ import org.apache.commons.jcs.yajcache.lang.annotation.*;
public class CacheRemoveEvent<V> extends CacheChangeEvent<V> {
private final @NonNullable String key;
- public CacheRemoveEvent(@NonNullable ICache<V> cache,
- @NonNullable String key)
+ public CacheRemoveEvent(@NonNullable final ICache<V> cache,
+ @NonNullable final String key)
{
super(cache);
this.key = key;
@@ -37,7 +37,7 @@ public class CacheRemoveEvent<V> extends CacheChangeEvent<V> {
return key;
}
@Override
- public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
+ public boolean dispatch(@NonNullable final ICacheChangeHandler<V> handler) {
return handler.handleRemove(super.getCache().getName(), this.key);
}
}
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/core/CacheEntry.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/core/CacheEntry.java
index f3bf1551..a2316f3a 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/core/CacheEntry.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/core/CacheEntry.java
@@ -32,21 +32,24 @@ public class CacheEntry<V> implements Map.Entry<String,V> {
private @NonNullable final String key;
private @NonNullable V value;
/** Creates a new instance of CacheEntry */
- public CacheEntry(@NonNullable String key, @NonNullable V val) {
+ public CacheEntry(@NonNullable final String key, @NonNullable final V val) {
this.key = key;
this.value = val;
}
+ @Override
public @NonNullable String getKey() {
return key;
}
+ @Override
public @NonNullable V getValue() {
return value;
}
- public V setValue(@NonNullable V val) {
- V ret = this.value;
+ @Override
+ public V setValue(@NonNullable final V val) {
+ final V ret = this.value;
this.value = val;
return ret;
}
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/file/CacheFileContent.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/file/CacheFileContent.java
index a62b05f1..d8fd7300 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/file/CacheFileContent.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/file/CacheFileContent.java
@@ -58,8 +58,8 @@ public class CacheFileContent {
* and content.
*/
private CacheFileContent(
- @NonNullable CacheFileContentType contentType,
- @NonNullable byte[] content)
+ @NonNullable final CacheFileContentType contentType,
+ @NonNullable final byte[] content)
{
this.contentType = contentType.toByte();
this.content = content;
@@ -69,7 +69,7 @@ public class CacheFileContent {
/**
* Write the current cache file content to the given random access file.
*/
- void write(@NonNullable RandomAccessFile raf) throws IOException {
+ void write(@NonNullable final RandomAccessFile raf) throws IOException {
// File content type.
raf.writeByte(this.contentType);
// Byte array length.
@@ -84,7 +84,7 @@ public class CacheFileContent {
return content;
}
- public void setContent(byte[] content) {
+ public void setContent(final byte[] content) {
this.content = content == null ? new byte[0] : content;
}
@@ -92,7 +92,7 @@ public class CacheFileContent {
return contentType;
}
- public void setContentType(byte contentType) {
+ public void setContentType(final byte contentType) {
this.contentType = contentType;
}
@@ -100,7 +100,7 @@ public class CacheFileContent {
return contentLength;
}
- void setContentLength(int contentLength) {
+ void setContentLength(final int contentLength) {
this.contentLength = contentLength;
}
@@ -108,7 +108,7 @@ public class CacheFileContent {
return contentHashCode;
}
- void setContentHashCode(int contentHashCode) {
+ void setContentHashCode(final int contentHashCode) {
this.contentHashCode = contentHashCode;
}
/**
@@ -116,7 +116,7 @@ public class CacheFileContent {
* the content.
*/
public boolean isValid() {
- int hash = Arrays.hashCode(this.content);
+ final int hash = Arrays.hashCode(this.content);
return hash == this.contentHashCode;
}
/**
@@ -125,8 +125,8 @@ public class CacheFileContent {
*/
@NonNullable
static CacheFileContent getInstance(
- @NonNullable CacheFileContentType contentType,
- @NonNullable byte[] content)
+ @NonNullable final CacheFileContentType contentType,
+ @NonNullable final byte[] content)
throws IOException
{
return new CacheFileContent(contentType, content);
@@ -135,15 +135,15 @@ public class CacheFileContent {
* Returns an instance of CacheFileContent from the given random access file;
*/
@NonNullable
- static CacheFileContent getInstance(@NonNullable RandomAccessFile raf)
+ static CacheFileContent getInstance(@NonNullable final RandomAccessFile raf)
throws IOException
{
- CacheFileContent cfc = new CacheFileContent();
+ final CacheFileContent cfc = new CacheFileContent();
cfc.setContentType(raf.readByte());
final int len = raf.readInt();
cfc.setContentLength(len);
cfc.setContentHashCode(raf.readInt());
- byte[] ba = new byte[len];
+ final byte[] ba = new byte[len];
// Byte array.
raf.readFully(ba);
cfc.setContent(ba);
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/util/ClassUtils.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/util/ClassUtils.java
index c5886e55..a0a86c46 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/util/ClassUtils.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/util/ClassUtils.java
@@ -33,7 +33,7 @@ public enum ClassUtils {
* Returns true if instances of the given class is known to be immutable;
* false if we don't know.
*/
- public boolean isImmutable(@NonNullable Class t) {
+ public boolean isImmutable(@NonNullable final Class t) {
return t == String.class
|| t.isPrimitive()
|| t == Boolean.class
@@ -49,7 +49,7 @@ public enum ClassUtils {
|| t.isEnum()
;
}
- public boolean isImmutable(@NonNullable Object obj) {
+ public boolean isImmutable(@NonNullable final Object obj) {
return this.isImmutable(obj.getClass());
}
}
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/test/java/org/apache/commons/jcs/yajcache/core/CacheManagerTest.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/test/java/org/apache/commons/jcs/yajcache/core/CacheManagerTest.java
index a302071c..002cd083 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/test/java/org/apache/commons/jcs/yajcache/core/CacheManagerTest.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/test/java/org/apache/commons/jcs/yajcache/core/CacheManagerTest.java
@@ -31,7 +31,7 @@ import org.apache.commons.logging.LogFactory;
@CopyRightApache
@TestOnly
public class CacheManagerTest extends TestCase {
- private Log log = LogFactory.getLog(this.getClass());
+ private final Log log = LogFactory.getLog(this.getClass());
public void testGetCache() {
CacheManager.inst.getCache("myCache", String.class);
@@ -63,13 +63,13 @@ public class CacheManagerTest extends TestCase {
assertTrue(null == c.get("2"));
assertTrue(null == c.get("1"));
log.debug("Test getCache and getValueType");
- ICache c1 = CacheManager.inst.getCache("myCache");
+ final ICache c1 = CacheManager.inst.getCache("myCache");
assertTrue(c1.getValueType() == String.class);
log.debug("Test checking of cache value type");
try {
- ICache<Integer> c2 = CacheManager.inst.getCache("myCache", Integer.class);
+ final ICache<Integer> c2 = CacheManager.inst.getCache("myCache", Integer.class);
assert false : "Bug: Cache for string cannot be used for Integer";
- } catch (ClassCastException ex) {
+ } catch (final ClassCastException ex) {
// should go here.
}
log.debug(CacheManager.inst);
@@ -77,18 +77,18 @@ public class CacheManagerTest extends TestCase {
public void testGetCacheRaceCondition() {
log.debug("Test simulation of race condition in creating cache");
- ICache intCache = CacheManager.inst.testCreateCacheRaceCondition(
+ final ICache intCache = CacheManager.inst.testCreateCacheRaceCondition(
"race", Integer.class, CacheType.SOFT_REFERENCE);
- ICache intCache1 = CacheManager.inst.testCreateCacheRaceCondition(
+ final ICache intCache1 = CacheManager.inst.testCreateCacheRaceCondition(
"race", Integer.class, CacheType.SOFT_REFERENCE);
log.debug("Test simulation of the worst case scenario: "
+ "race condition in creating cache AND class cast exception");
try {
- ICache<Double> doubleCache =
+ final ICache<Double> doubleCache =
CacheManager.inst.testCreateCacheRaceCondition(
"race", Double.class, CacheType.SOFT_REFERENCE);
assert false : "Bug: Cache for Integer cannot be used for Double";
- } catch (ClassCastException ex) {
+ } catch (final ClassCastException ex) {
// should go here.
}
assertTrue(intCache == intCache1);
@@ -97,15 +97,15 @@ public class CacheManagerTest extends TestCase {
public void testRemoveCache() {
log.debug("Test remove cache");
- ICache<Integer> intCache = CacheManager.inst.getCache("race", Integer.class);
+ final ICache<Integer> intCache = CacheManager.inst.getCache("race", Integer.class);
intCache.put("1", 1);
assertEquals(intCache.size(), 1);
assertEquals(intCache, CacheManager.inst.removeCache("race"));
assertEquals(intCache.size(), 0);
- ICache intCache1 = CacheManager.inst.getCache("race", Integer.class);
+ final ICache intCache1 = CacheManager.inst.getCache("race", Integer.class);
assertFalse(intCache == intCache1);
CacheManager.inst.removeCache("race");
- ICache<Double> doubleCache = CacheManager.inst.testCreateCacheRaceCondition(
+ final ICache<Double> doubleCache = CacheManager.inst.testCreateCacheRaceCondition(
"race", Double.class, CacheType.SOFT_REFERENCE);
doubleCache.put("double", 1.234);
assertEquals(1.234, doubleCache.get("double"));