#39 Get rid of anonymous inner class in ThreadLocal as it might possibly trigger a warning in Tomcat.

pull/41/head
Brett Wooldridge 11 years ago
parent 83b88f675e
commit 07d630de5a

@ -74,12 +74,7 @@ public class ConcurrentBag<T extends com.zaxxer.hikari.util.ConcurrentBag.IBagMa
{ {
this.sharedList = new CopyOnWriteArraySet<>(); this.sharedList = new CopyOnWriteArraySet<>();
this.synchronizer = new Synchronizer(); this.synchronizer = new Synchronizer();
this.threadList = new ThreadLocal<LinkedList<T>>() { this.threadList = new ThreadLocal<LinkedList<T>>();
protected LinkedList<T> initialValue()
{
return new LinkedList<>();
}
};
} }
/** /**
@ -94,7 +89,13 @@ public class ConcurrentBag<T extends com.zaxxer.hikari.util.ConcurrentBag.IBagMa
public T borrow(long timeout, TimeUnit timeUnit) throws InterruptedException public T borrow(long timeout, TimeUnit timeUnit) throws InterruptedException
{ {
// Try the thread-local list first // Try the thread-local list first
final LinkedList<T> list = threadList.get(); LinkedList<T> list = threadList.get();
if (list == null)
{
list = new LinkedList<>();
threadList.set(list);
}
while (!list.isEmpty()) while (!list.isEmpty())
{ {
final T reference = list.removeFirst(); final T reference = list.removeFirst();

Loading…
Cancel
Save