From ac73fdb6edf67652785aa58b5b205b2e61c1e417 Mon Sep 17 00:00:00 2001 From: Driptaroop Das Date: Thu, 28 Feb 2019 01:01:38 +0530 Subject: CachedElement.java - Sonar Fixes CachedElement.java - Sonar Fixes Issue-ID: APPC-1508 Change-Id: I24bdb1ab1e3c00975eba4ea92dcf34b8e26849dc Signed-off-by: Driptaroop Das --- .../src/main/java/org/onap/appc/pool/CachedElement.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'appc-core/appc-common-bundle') 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 CachedElement 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 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": -- cgit 1.2.3-korg