This commit is contained in:
kamhung
2015-11-30 17:54:40 +08:00
parent 2ec86dab2a
commit c5b99daa64

View File

@@ -77,9 +77,14 @@ public final class ObjectPool<T> implements Supplier<T> {
public void offer(final T e) { public void offer(final T e) {
if (e != null && recycler.test(e)) { if (e != null && recycler.test(e)) {
if (cycleCounter != null) cycleCounter.incrementAndGet(); if (cycleCounter != null) cycleCounter.incrementAndGet();
if (debug) queue.forEach(t -> { if (debug) {
if (t == e) logger.log(Level.WARNING, "[" + Thread.currentThread().getName() + "] repeat offer the same object(" + e + ")", new Exception()); for (T t : queue) {
}); if (t == e) {
logger.log(Level.WARNING, "[" + Thread.currentThread().getName() + "] repeat offer the same object(" + e + ")", new Exception());
return;
}
}
}
queue.offer(e); queue.offer(e);
} }
} }