< prev index next >

src/java.naming/share/classes/com/sun/jndi/ldap/pool/Connections.java

Print this page

        

*** 25,35 **** package com.sun.jndi.ldap.pool; import java.util.ArrayList; // JDK 1.2 import java.util.List; - import java.util.Iterator; import java.lang.ref.Reference; import java.lang.ref.SoftReference; import javax.naming.NamingException; --- 25,34 ----
*** 289,315 **** * * @param threshold an entry idle since this time has expired. * @return true if no more connections in list */ synchronized boolean expire(long threshold) { ! Iterator<ConnectionDesc> iter = conns.iterator(); ! ConnectionDesc entry; ! while (iter.hasNext()) { ! entry = iter.next(); ! if (entry.expire(threshold)) { ! d("expire(): removing ", entry); ! td("Expired ", entry); ! iter.remove(); // remove from pool // Don't need to call notify() because we're // removing only idle connections. If there were // idle connections, then there should be no waiters. - } - } return conns.isEmpty(); // whether whole list has 'expired' } /** * Called when this instance of Connections has been removed from Pool. * This means that no one can get any pooled connections from this * Connections any longer. Expire all idle connections as of 'now' --- 288,319 ---- * * @param threshold an entry idle since this time has expired. * @return true if no more connections in list */ synchronized boolean expire(long threshold) { ! List<ConnectionDesc> clonedConns; ! synchronized(this) { ! clonedConns = new ArrayList<>(conns); ! } ! List<ConnectionDesc> expired = new ArrayList<>(); ! for (ConnectionDesc entry : clonedConns) { ! d("expire(): ", entry); ! if (entry.expire(threshold)) { ! expired.add(entry); ! td("expire(): Expired ", entry); ! } ! } + synchronized (this) { + conns.removeAll(expired); // Don't need to call notify() because we're // removing only idle connections. If there were // idle connections, then there should be no waiters. return conns.isEmpty(); // whether whole list has 'expired' } + } /** * Called when this instance of Connections has been removed from Pool. * This means that no one can get any pooled connections from this * Connections any longer. Expire all idle connections as of 'now'
< prev index next >