* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
+ * Modifications Copyright (C) 2019 IBM
+ * =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
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;
public class CachedElement<T extends Closeable>
implements Closeable, InvocationHandler, CacheManagement {
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(CachedElement.class);
/**
* The pool that is managing this cached element
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;
}
try {
pool.release((T) this);
} catch (PoolDrainedException e) {
- e.printStackTrace();
+ LOG.error("Pool is empty", e);
}
}
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":