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

Print this page

        

*** 69,82 **** com.sun.jndi.ldap.LdapPoolManager.trace; private static final int DEFAULT_SIZE = 10; final private int maxSize; final private int prefSize; ! final private List conns; private boolean closed = false; // Closed for business ! private Reference ref; // maintains reference to id to prevent premature GC /** * @param id the identity (connection request) of the connections in the list * @param initSize the number of connections to create initially * @param prefSize the preferred size of the pool. The pool will try --- 69,82 ---- com.sun.jndi.ldap.LdapPoolManager.trace; private static final int DEFAULT_SIZE = 10; final private int maxSize; final private int prefSize; ! final private List<ConnectionDesc> conns; private boolean closed = false; // Closed for business ! private Reference<Object> ref; // maintains reference to id to prevent premature GC /** * @param id the identity (connection request) of the connections in the list * @param initSize the number of connections to create initially * @param prefSize the preferred size of the pool. The pool will try
*** 97,111 **** this.prefSize = Math.min(prefSize, maxSize); initSize = Math.min(initSize, maxSize); } else { this.prefSize = prefSize; } ! conns = new ArrayList(maxSize > 0 ? maxSize : DEFAULT_SIZE); // Maintain soft ref to id so that this Connections' entry in // Pool doesn't get GC'ed prematurely ! ref = new SoftReference(id); d("init size=", initSize); d("max size=", maxSize); d("preferred size=", prefSize); --- 97,111 ---- this.prefSize = Math.min(prefSize, maxSize); initSize = Math.min(initSize, maxSize); } else { this.prefSize = prefSize; } ! conns = new ArrayList<>(maxSize > 0 ? maxSize : DEFAULT_SIZE); // Maintain soft ref to id so that this Connections' entry in // Pool doesn't get GC'ed prematurely ! ref = new SoftReference<>(id); d("init size=", initSize); d("max size=", maxSize); d("preferred size=", prefSize);
*** 184,194 **** if (prefSize <= 0 || size >= prefSize) { // If no prefSize specified, or list size already meets or // exceeds prefSize, then first look for an idle connection ConnectionDesc entry; for (int i = 0; i < size; i++) { ! entry = (ConnectionDesc) conns.get(i); if ((conn = entry.tryUse()) != null) { d("get(): use ", conn); td("Use ", conn); return conn; } --- 184,194 ---- if (prefSize <= 0 || size >= prefSize) { // If no prefSize specified, or list size already meets or // exceeds prefSize, then first look for an idle connection ConnectionDesc entry; for (int i = 0; i < size; i++) { ! entry = conns.get(i); if ((conn = entry.tryUse()) != null) { d("get(): use ", conn); td("Use ", conn); return conn; }
*** 237,247 **** } else { d("release(): release ", conn); td("Release ", conn); // Get ConnectionDesc from list to get correct state info ! entry = (ConnectionDesc) conns.get(loc); // Return connection to list, ready for reuse entry.release(); } notifyAll(); d("release(): notify"); --- 237,247 ---- } else { d("release(): release ", conn); td("Release ", conn); // Get ConnectionDesc from list to get correct state info ! entry = conns.get(loc); // Return connection to list, ready for reuse entry.release(); } notifyAll(); d("release(): notify");
*** 289,302 **** * * @param threshold an entry idle since this time has expired. * @return true if no more connections in list */ synchronized boolean expire(long threshold) { ! Iterator iter = conns.iterator(); ConnectionDesc entry; while (iter.hasNext()) { ! entry = (ConnectionDesc) iter.next(); if (entry.expire(threshold)) { d("expire(): removing ", entry); td("Expired ", entry); iter.remove(); // remove from pool --- 289,302 ---- * * @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
*** 331,341 **** synchronized (this) { len = conns.size(); ConnectionDesc entry; for (int i = 0; i < len; i++) { ! entry = (ConnectionDesc) conns.get(i); use += entry.getUseCount(); switch (entry.getState()) { case ConnectionDesc.BUSY: ++busy; break; --- 331,341 ---- synchronized (this) { len = conns.size(); ConnectionDesc entry; for (int i = 0; i < len; i++) { ! entry = conns.get(i); use += entry.getUseCount(); switch (entry.getState()) { case ConnectionDesc.BUSY: ++busy; break;