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 2021/11/22 19:14:16 UTC
[commons-jcs] 03/07: Use same coding patterns
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 9263fe12c953bb70961cf16ad11a07e23da97b96
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Mon Nov 22 17:57:53 2021 +0100
Use same coding patterns
---
.../jcs3/auxiliary/lateral/LateralCache.java | 48 +++++++++++-----------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java
index 0688fde..d4055e2 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java
@@ -124,19 +124,19 @@ public class LateralCache<K, V>
{
ICacheElement<K, V> obj = null;
- if ( this.lateralCacheAttributes.getPutOnlyMode() )
+ if ( !this.lateralCacheAttributes.getPutOnlyMode() )
{
- return null;
- }
- try
- {
- obj = lateralCacheService.get( cacheName, key );
- }
- catch ( final Exception e )
- {
- log.error( e );
- handleException( e, "Failed to get [" + key + "] from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes );
+ try
+ {
+ obj = lateralCacheService.get( cacheName, key );
+ }
+ catch ( final Exception e )
+ {
+ log.error( e );
+ handleException( e, "Failed to get [" + key + "] from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes );
+ }
}
+
return obj;
}
@@ -150,20 +150,22 @@ public class LateralCache<K, V>
protected Map<K, ICacheElement<K, V>> processGetMatching( final String pattern )
throws IOException
{
- if ( this.lateralCacheAttributes.getPutOnlyMode() )
- {
- return Collections.emptyMap();
- }
- try
- {
- return lateralCacheService.getMatching( cacheName, pattern );
- }
- catch ( final IOException e )
+ Map<K, ICacheElement<K, V>> map = Collections.emptyMap();
+
+ if ( !this.lateralCacheAttributes.getPutOnlyMode() )
{
- log.error( e );
- handleException( e, "Failed to getMatching [" + pattern + "] from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes );
- return Collections.emptyMap();
+ try
+ {
+ return lateralCacheService.getMatching( cacheName, pattern );
+ }
+ catch ( final IOException e )
+ {
+ log.error( e );
+ handleException( e, "Failed to getMatching [" + pattern + "] from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes );
+ }
}
+
+ return map;
}
/**