diff options
author | Driptaroop Das <driptaroop.das@in.ibm.com> | 2019-02-28 01:01:38 +0530 |
---|---|---|
committer | Takamune Cho <takamune.cho@att.com> | 2019-02-28 14:45:45 +0000 |
commit | ac73fdb6edf67652785aa58b5b205b2e61c1e417 (patch) | |
tree | a2f0c95fab9699656f8da16bf5d6ec20039107b3 /appc-core | |
parent | b5a393e2a1032f3132582426e8875de99e559061 (diff) |
CachedElement.java - Sonar Fixes
CachedElement.java - Sonar Fixes
Issue-ID: APPC-1508
Change-Id: I24bdb1ab1e3c00975eba4ea92dcf34b8e26849dc
Signed-off-by: Driptaroop Das <driptaroop.das@in.ibm.com>
Diffstat (limited to 'appc-core')
-rw-r--r-- | appc-core/appc-common-bundle/src/main/java/org/onap/appc/pool/CachedElement.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/appc-core/appc-common-bundle/src/main/java/org/onap/appc/pool/CachedElement.java b/appc-core/appc-common-bundle/src/main/java/org/onap/appc/pool/CachedElement.java index 093ce10bc..c070a17a5 100644 --- a/appc-core/appc-common-bundle/src/main/java/org/onap/appc/pool/CachedElement.java +++ b/appc-core/appc-common-bundle/src/main/java/org/onap/appc/pool/CachedElement.java @@ -25,14 +25,15 @@ package org.onap.appc.pool; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + import java.io.Closeable; import java.io.IOException; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.concurrent.atomic.AtomicBoolean; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; /** * This class is used as a "wrapper" for any closeable elements that are cached in a pool. It is @@ -90,7 +91,7 @@ public class CachedElement<T extends Closeable> CachedElement<T> ce = new CachedElement<>(pool, element); boolean found = false; for (Class<?> intf : interfaces) { - if (intf.getName().equals(CacheManagement.class.getName())) { + if (intf.isAssignableFrom(CacheManagement.class)) { found = true; break; } @@ -180,10 +181,8 @@ public class CachedElement<T extends Closeable> switch (method.getName()) { case "close": - if (released.compareAndSet(false, true)) { - if (!pool.isDrained()) { - pool.release((T) proxy); - } + if (released.compareAndSet(false, true) && !pool.isDrained()) { + pool.release((T) proxy); } break; case "equals": |