< prev index next >

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

Print this page

        

*** 23,37 **** * questions. */ package com.sun.jndi.ldap.pool; import java.util.Map; import java.util.WeakHashMap; import java.util.Collection; import java.util.Collections; - import java.util.Iterator; import java.util.LinkedList; import java.io.PrintStream; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; --- 23,37 ---- * questions. */ package com.sun.jndi.ldap.pool; + import java.util.ArrayList; import java.util.Map; import java.util.WeakHashMap; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.io.PrintStream; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue;
*** 164,184 **** * * @param threshold connections idle before 'threshold' should be closed * and removed. */ public void expire(long threshold) { synchronized (map) { ! Iterator<ConnectionsRef> iter = map.values().iterator(); Connections conns; ! while (iter.hasNext()) { ! conns = iter.next().getConnections(); if (conns.expire(threshold)) { d("expire(): removing ", conns); ! iter.remove(); } } } expungeStaleConnections(); } /* * Closes the connections contained in the ConnectionsRef object that --- 164,192 ---- * * @param threshold connections idle before 'threshold' should be closed * and removed. */ public void expire(long threshold) { + Collection<ConnectionsRef> copy; synchronized (map) { ! copy = new ArrayList<>(map.values()); ! } ! ! ArrayList<ConnectionsRef> removed = new ArrayList<>(); Connections conns; ! for (ConnectionsRef ref : copy) { ! conns = ref.getConnections(); if (conns.expire(threshold)) { d("expire(): removing ", conns); ! removed.add(ref); } } + + synchronized (map) { + map.values().removeAll(removed); } + expungeStaleConnections(); } /* * Closes the connections contained in the ConnectionsRef object that
< prev index next >