This is an automated email from the ASF dual-hosted git repository.

tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git

commit e1db1e56af16fd7526e4ac2967a6ad8cc880597b
Author: Thomas Vandahl <[email protected]>
AuthorDate: Sat Mar 27 19:07:09 2021 +0100

    Try to fix several type safety problems
---
 .../org/apache/commons/jcs3/jcache/EvictionListener.java  |  4 +++-
 .../java/org/apache/commons/jcs3/jcache/JCSCache.java     |  4 ++--
 .../org/apache/commons/jcs3/jcache/JCSCachingManager.java |  2 ++
 .../java/org/apache/commons/jcs3/jcache/JCSListener.java  | 15 ++++++++-------
 .../java/org/apache/commons/jcs3/jcache/NoLoader.java     |  7 ++++---
 .../java/org/apache/commons/jcs3/jcache/NoWriter.java     | 15 +++++----------
 6 files changed, 24 insertions(+), 23 deletions(-)

diff --git 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/EvictionListener.java
 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/EvictionListener.java
index 111b04c..6a673fc 100644
--- 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/EvictionListener.java
+++ 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/EvictionListener.java
@@ -31,7 +31,7 @@ public class EvictionListener implements IElementEventHandler
     }
 
     @Override
-    public void handleElementEvent(final IElementEvent event)
+    public <T> void handleElementEvent(final IElementEvent<T> event)
     {
         switch (event.getElementEvent())
         {
@@ -41,6 +41,8 @@ public class EvictionListener implements IElementEventHandler
             case EXCEEDED_IDLETIME_BACKGROUND:
                 stats.increaseEvictions(1);
                 break;
+            default:
+                break;
         }
     }
 }
diff --git 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCache.java 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCache.java
index e7c3a29..6bde9aa 100644
--- 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCache.java
+++ 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCache.java
@@ -120,7 +120,7 @@ public class JCSCache<K, V> implements Cache<K, V>
         final Factory<CacheLoader<K, V>> cacheLoaderFactory = 
configuration.getCacheLoaderFactory();
         if (cacheLoaderFactory == null)
         {
-            loader = NoLoader.INSTANCE;
+            loader = (CacheLoader<K, V>) NoLoader.INSTANCE;
         }
         else
         {
@@ -131,7 +131,7 @@ public class JCSCache<K, V> implements Cache<K, V>
         final Factory<CacheWriter<? super K, ? super V>> cacheWriterFactory = 
configuration.getCacheWriterFactory();
         if (cacheWriterFactory == null)
         {
-            writer = NoWriter.INSTANCE;
+            writer = (CacheWriter<K, V>) NoWriter.INSTANCE;
         }
         else
         {
diff --git 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCachingManager.java
 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCachingManager.java
index efa5dc4..62690ed 100644
--- 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCachingManager.java
+++ 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSCachingManager.java
@@ -351,12 +351,14 @@ public class JCSCachingManager implements CacheManager
 
     private <K, V> Cache<K, V> doGetCache(final String cacheName, final 
Class<K> keyType, final Class<V> valueType)
     {
+        @SuppressWarnings("unchecked") // common map for all caches
         final Cache<K, V> cache = (Cache<K, V>) caches.get(cacheName);
         if (cache == null)
         {
             return null;
         }
 
+        @SuppressWarnings("unchecked") // don't know how to solve this
         final Configuration<K, V> config = 
cache.getConfiguration(Configuration.class);
         if ((keyType != null && !config.getKeyType().isAssignableFrom(keyType))
                 || (valueType != null && 
!config.getValueType().isAssignableFrom(valueType)))
diff --git 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSListener.java
 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSListener.java
index b0387e4..fd29c8d 100644
--- 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSListener.java
+++ 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/JCSListener.java
@@ -18,6 +18,10 @@
  */
 package org.apache.commons.jcs3.jcache;
 
+import java.io.Closeable;
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.cache.configuration.CacheEntryListenerConfiguration;
 import javax.cache.configuration.Factory;
 import javax.cache.event.CacheEntryCreatedListener;
@@ -28,14 +32,11 @@ import javax.cache.event.CacheEntryListener;
 import javax.cache.event.CacheEntryListenerException;
 import javax.cache.event.CacheEntryRemovedListener;
 import javax.cache.event.CacheEntryUpdatedListener;
-import java.io.Closeable;
-import java.util.ArrayList;
-import java.util.List;
 
 public class JCSListener<K, V> implements Closeable
 {
-    private final boolean oldValue;
-    private final boolean synchronous;
+//    private final boolean oldValue;
+//    private final boolean synchronous;
     private final CacheEntryEventFilter<? super K, ? super V> filter;
     private final CacheEntryListener<? super K, ? super V> delegate;
     private final boolean remove;
@@ -45,8 +46,8 @@ public class JCSListener<K, V> implements Closeable
 
     public JCSListener(final CacheEntryListenerConfiguration<K, V> 
cacheEntryListenerConfiguration)
     {
-        oldValue = cacheEntryListenerConfiguration.isOldValueRequired();
-        synchronous = cacheEntryListenerConfiguration.isSynchronous();
+//        oldValue = cacheEntryListenerConfiguration.isOldValueRequired();
+//        synchronous = cacheEntryListenerConfiguration.isSynchronous();
 
         final Factory<CacheEntryEventFilter<? super K, ? super V>> 
filterFactory = cacheEntryListenerConfiguration
                 .getCacheEntryEventFilterFactory();
diff --git 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/NoLoader.java 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/NoLoader.java
index da0ee3d..091cd31 100644
--- 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/NoLoader.java
+++ 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/NoLoader.java
@@ -18,14 +18,15 @@
  */
 package org.apache.commons.jcs3.jcache;
 
-import javax.cache.integration.CacheLoader;
-import javax.cache.integration.CacheLoaderException;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.cache.integration.CacheLoader;
+import javax.cache.integration.CacheLoaderException;
+
 public class NoLoader<K, V> implements CacheLoader<K, V>
 {
-    public static final NoLoader INSTANCE = new NoLoader();
+    public static final NoLoader<?, ?> INSTANCE = new NoLoader<>();
 
     private NoLoader()
     {
diff --git 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/NoWriter.java 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/NoWriter.java
index 939d3a6..a130e9d 100644
--- 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/NoWriter.java
+++ 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/NoWriter.java
@@ -18,14 +18,15 @@
  */
 package org.apache.commons.jcs3.jcache;
 
+import java.util.Collection;
+
 import javax.cache.Cache;
 import javax.cache.integration.CacheWriter;
 import javax.cache.integration.CacheWriterException;
-import java.util.Collection;
 
 public class NoWriter<K, V> implements CacheWriter<K, V>
 {
-    public static final NoWriter INSTANCE = new NoWriter();
+    public static final NoWriter<?, ?> INSTANCE = new NoWriter<>();
 
     @Override
     public void write(final Cache.Entry<? extends K, ? extends V> entry) 
throws CacheWriterException
@@ -42,18 +43,12 @@ public class NoWriter<K, V> implements CacheWriter<K, V>
     @Override
     public void writeAll(final Collection<Cache.Entry<? extends K, ? extends 
V>> entries) throws CacheWriterException
     {
-        for (final Cache.Entry<? extends K, ? extends V> entry : entries)
-        {
-            write(entry);
-        }
+        entries.forEach(this::write);
     }
 
     @Override
     public void deleteAll(final Collection<?> keys) throws CacheWriterException
     {
-        for (final Object k : keys)
-        {
-            delete(k);
-        }
+        keys.forEach(this::delete);
     }
 }

Reply via email to