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


The following commit(s) were added to refs/heads/master by this push:
     new 0e515c3  Raise embedded if into parent if.
0e515c3 is described below

commit 0e515c37174f86e965f0e6c9fb4d99ba43e86359
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Feb 28 12:41:23 2021 -0500

    Raise embedded if into parent if.
---
 .../jcs3/auxiliary/disk/AbstractDiskCache.java     |  7 ++---
 .../auxiliary/disk/jdbc/mysql/MySQLDiskCache.java  | 28 ++++++------------
 .../lateral/socket/tcp/LateralTCPListener.java     | 33 ++++++++++------------
 .../remote/AbstractRemoteAuxiliaryCache.java       | 15 ++++------
 .../commons/jcs3/auxiliary/remote/RemoteUtils.java |  9 ++----
 .../remote/http/server/RemoteHttpCacheServlet.java |  7 ++---
 .../auxiliary/remote/server/RemoteCacheServer.java |  7 ++---
 .../engine/control/CompositeCacheConfigurator.java |  9 ++----
 .../jcs3/jcache/cdi/CachePutInterceptor.java       |  7 ++---
 .../jcs3/jcache/cdi/CacheRemoveAllInterceptor.java |  7 ++---
 .../jcs3/jcache/cdi/CacheRemoveInterceptor.java    |  7 ++---
 11 files changed, 47 insertions(+), 89 deletions(-)

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 f4a59b7..331d9e7 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
@@ -674,12 +674,9 @@ public abstract class AbstractDiskCache<K, V>
         public void handleRemove( final String cacheName, final K key )
             throws IOException
         {
-            if ( alive )
+            if ( alive && doRemove( key ) )
             {
-                if ( doRemove( key ) )
-                {
-                    log.debug( "Element removed, key: " + key );
-                }
+                log.debug( "Element removed, key: " + key );
             }
         }
 
diff --git 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
index 973f9e2..8934f05 100644
--- 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
+++ 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
@@ -75,12 +75,9 @@ public class MySQLDiskCache<K, V>
     @Override
     protected ICacheElement<K, V> processGet( final K key )
     {
-        if ( this.getTableState().getState() == 
TableState.OPTIMIZATION_RUNNING )
+        if ( (this.getTableState().getState() == 
TableState.OPTIMIZATION_RUNNING) && 
this.mySQLDiskCacheAttributes.isBalkDuringOptimization() )
         {
-            if ( this.mySQLDiskCacheAttributes.isBalkDuringOptimization() )
-            {
-                return null;
-            }
+            return null;
         }
         return super.processGet( key );
     }
@@ -95,12 +92,9 @@ public class MySQLDiskCache<K, V>
     @Override
     protected Map<K, ICacheElement<K, V>> processGetMatching( final String 
pattern )
     {
-        if ( this.getTableState().getState() == 
TableState.OPTIMIZATION_RUNNING )
+        if ( (this.getTableState().getState() == 
TableState.OPTIMIZATION_RUNNING) && 
this.mySQLDiskCacheAttributes.isBalkDuringOptimization() )
         {
-            if ( this.mySQLDiskCacheAttributes.isBalkDuringOptimization() )
-            {
-                return null;
-            }
+            return null;
         }
         return super.processGetMatching( pattern );
     }
@@ -129,12 +123,9 @@ public class MySQLDiskCache<K, V>
     @Override
     protected void processUpdate( final ICacheElement<K, V> element )
     {
-        if ( this.getTableState().getState() == 
TableState.OPTIMIZATION_RUNNING )
+        if ( (this.getTableState().getState() == 
TableState.OPTIMIZATION_RUNNING) && 
this.mySQLDiskCacheAttributes.isBalkDuringOptimization() )
         {
-            if ( this.mySQLDiskCacheAttributes.isBalkDuringOptimization() )
-            {
-                return;
-            }
+            return;
         }
         super.processUpdate( element );
     }
@@ -151,12 +142,9 @@ public class MySQLDiskCache<K, V>
     @Override
     protected int deleteExpired()
     {
-        if ( this.getTableState().getState() == 
TableState.OPTIMIZATION_RUNNING )
+        if ( (this.getTableState().getState() == 
TableState.OPTIMIZATION_RUNNING) && 
this.mySQLDiskCacheAttributes.isBalkDuringOptimization() )
         {
-            if ( this.mySQLDiskCacheAttributes.isBalkDuringOptimization() )
-            {
-                return -1;
-            }
+            return -1;
         }
         return super.deleteExpired();
     }
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 32111f8..831ef53 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
@@ -598,28 +598,25 @@ public class LateralTCPListener<K, V>
                 // if a hashcode was given and filtering is on
                 // check to see if they are the same
                 // if so, then don't remove, otherwise issue a remove
-                if ( led.valHashCode != -1 )
+            if ( (led.valHashCode != -1) && 
getTcpLateralCacheAttributes().isFilterRemoveByHashCode() )
+            {
+                final ICacheElement<K, V> test = getCache( cacheName 
).localGet( key );
+                if ( test != null )
                 {
-                    if ( 
getTcpLateralCacheAttributes().isFilterRemoveByHashCode() )
+                    if ( test.getVal().hashCode() == led.valHashCode )
+                    {
+                        log.debug( "Filtering detected identical hashCode 
[{0}], "
+                                + "not issuing a remove for led {1}",
+                                led.valHashCode, led );
+                        return;
+                    }
+                    else
                     {
-                        final ICacheElement<K, V> test = getCache( cacheName 
).localGet( key );
-                        if ( test != null )
-                        {
-                            if ( test.getVal().hashCode() == led.valHashCode )
-                            {
-                                log.debug( "Filtering detected identical 
hashCode [{0}], "
-                                        + "not issuing a remove for led {1}",
-                                        led.valHashCode, led );
-                                return;
-                            }
-                            else
-                            {
-                                log.debug( "Different hashcodes, in cache 
[{0}] sent [{1}]",
-                                        test.getVal().hashCode(), 
led.valHashCode );
-                            }
-                        }
+                        log.debug( "Different hashcodes, in cache [{0}] sent 
[{1}]",
+                                test.getVal().hashCode(), led.valHashCode );
                     }
                 }
+            }
                 handleRemove( cacheName, key );
                 break;
 
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 a178b9f..5445f97 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
@@ -171,16 +171,13 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
             }
 
             // Eventually the instance of will not be necessary.
-            if ( retVal instanceof ICacheElementSerialized )
+            // Never try to deserialize if you are a cluster client. Cluster
+            // clients are merely intra-remote cache communicators. Remote 
caches are assumed
+            // to have no ability to deserialize the objects.
+            if ( (retVal instanceof ICacheElementSerialized) && 
(this.getRemoteCacheAttributes().getRemoteType() != RemoteType.CLUSTER) )
             {
-                // Never try to deserialize if you are a cluster client. 
Cluster
-                // clients are merely intra-remote cache communicators. Remote 
caches are assumed
-                // to have no ability to deserialize the objects.
-                if ( this.getRemoteCacheAttributes().getRemoteType() != 
RemoteType.CLUSTER )
-                {
-                    retVal = 
SerializationConversionUtil.getDeSerializedCacheElement( 
(ICacheElementSerialized<K, V>) retVal,
-                            super.getElementSerializer() );
-                }
+                retVal = 
SerializationConversionUtil.getDeSerializedCacheElement( 
(ICacheElementSerialized<K, V>) retVal,
+                        super.getElementSerializer() );
             }
         }
         catch ( final Exception ex )
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 fdd02a4..6b89900 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
@@ -119,13 +119,10 @@ public class RemoteUtils
     {
         InputStream is = RemoteUtils.class.getResourceAsStream(propFile);
 
-        if (null == is) // not found in class path
+        // Try root of class path
+        if ((null == is) && (propFile != null && !propFile.startsWith("/")))
         {
-            // Try root of class path
-            if (propFile != null && !propFile.startsWith("/"))
-            {
-                is = RemoteUtils.class.getResourceAsStream("/" + propFile);
-            }
+            is = RemoteUtils.class.getResourceAsStream("/" + propFile);
         }
 
         if (null == is) // not found in class path
diff --git 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
index 9aba440..896eba8 100644
--- 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
+++ 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
@@ -346,12 +346,9 @@ public class RemoteHttpCacheServlet
     {
         // not thread safe, but it doesn't have to be accurate
         serviceCalls++;
-        if ( log.isInfoEnabled() )
+        if ( log.isInfoEnabled() && (serviceCalls % logInterval == 0) )
         {
-            if ( serviceCalls % logInterval == 0 )
-            {
-                log.info( "serviceCalls = {0}", serviceCalls );
-            }
+            log.info( "serviceCalls = {0}", serviceCalls );
         }
     }
 
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 79fa7ea..f690300 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
@@ -349,12 +349,9 @@ public class RemoteCacheServer<K, V>
         // not thread safe, but it doesn't have to be 100% accurate
         puts++;
 
-        if ( log.isInfoEnabled() )
+        if ( log.isInfoEnabled() && (puts % logInterval == 0) )
         {
-            if ( puts % logInterval == 0 )
-            {
-                log.info( "puts = {0}", puts );
-            }
+            log.info( "puts = {0}", puts );
         }
 
         log.debug( "In update, put [{0}] in [{1}]",
diff --git 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheConfigurator.java
 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheConfigurator.java
index f50ed6b..d913088 100644
--- 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheConfigurator.java
+++ 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCacheConfigurator.java
@@ -232,13 +232,10 @@ public class CompositeCacheConfigurator
             // If value is not in the form ", appender.." or "", then we 
should set
             // the priority of the category.
 
-            if ( !( auxiliaries.startsWith( "," ) || auxiliaries.equals( "" ) 
) )
+            // just to be on the safe side...
+            if ( !( auxiliaries.startsWith( "," ) || auxiliaries.equals( "" ) 
) && !st.hasMoreTokens() )
             {
-                // just to be on the safe side...
-                if ( !st.hasMoreTokens() )
-                {
-                    return null;
-                }
+                return null;
             }
 
             AuxiliaryCache<K, V> auxCache;
diff --git 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CachePutInterceptor.java
 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CachePutInterceptor.java
index 3044dab..2cfe2f6 100644
--- 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CachePutInterceptor.java
+++ 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CachePutInterceptor.java
@@ -73,12 +73,9 @@ public class CachePutInterceptor implements Serializable
         }
         catch (final Throwable t)
         {
-            if (afterInvocation)
+            if (afterInvocation && helper.isIncluded(t.getClass(), 
cachePut.cacheFor(), cachePut.noCacheFor()))
             {
-                if (helper.isIncluded(t.getClass(), cachePut.cacheFor(), 
cachePut.noCacheFor()))
-                {
-                    cache.put(cacheKey, context.getValueParameter());
-                }
+                cache.put(cacheKey, context.getValueParameter());
             }
 
             throw t;
diff --git 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheRemoveAllInterceptor.java
 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheRemoveAllInterceptor.java
index f8ec3a8..207d3c4 100644
--- 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheRemoveAllInterceptor.java
+++ 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheRemoveAllInterceptor.java
@@ -69,12 +69,9 @@ public class CacheRemoveAllInterceptor implements 
Serializable
         }
         catch (final Throwable t)
         {
-            if (afterInvocation)
+            if (afterInvocation && helper.isIncluded(t.getClass(), 
methodMeta.getCacheRemoveAll().evictFor(), 
methodMeta.getCacheRemoveAll().noEvictFor()))
             {
-                if (helper.isIncluded(t.getClass(), 
methodMeta.getCacheRemoveAll().evictFor(), 
methodMeta.getCacheRemoveAll().noEvictFor()))
-                {
-                    cache.removeAll();
-                }
+                cache.removeAll();
             }
             throw t;
         }
diff --git 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheRemoveInterceptor.java
 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheRemoveInterceptor.java
index 31706f0..7a8bb5a 100644
--- 
a/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheRemoveInterceptor.java
+++ 
b/commons-jcs-jcache/src/main/java/org/apache/commons/jcs3/jcache/cdi/CacheRemoveInterceptor.java
@@ -73,12 +73,9 @@ public class CacheRemoveInterceptor implements Serializable
         }
         catch (final Throwable t)
         {
-            if (afterInvocation)
+            if (afterInvocation && helper.isIncluded(t.getClass(), 
cacheRemove.evictFor(), cacheRemove.noEvictFor()))
             {
-                if (helper.isIncluded(t.getClass(), cacheRemove.evictFor(), 
cacheRemove.noEvictFor()))
-                {
-                    cache.remove(cacheKey);
-                }
+                cache.remove(cacheKey);
             }
 
             throw t;

Reply via email to