geronimo-mail_2.1/geronimo-mail_2.1_provider/src/main/java/org/apache/geronimo/mail/store/imap/connection/IMAPConnectionPool.java [284:343]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    protected synchronized IMAPConnection getPoolConnection() throws MessagingException {
        // if the pool is closed, we can't process this 
        if (closed) {
            throw new StoreClosedException(store, "No Store connections available"); 
        }
        
        // we'll retry this a few times if the connection pool is full, but 
        // after that, we'll just create a new connection. 
        for (int i = 0; i < MAX_CONNECTION_RETRIES; i++) {
            Iterator it = availableConnections.iterator(); 
            while (it.hasNext()) {
                IMAPConnection connection = (IMAPConnection)it.next(); 
                // live or dead, we're going to remove this from the 
                // available list. 
                it.remove(); 
                if (connection.isAlive(poolTimeout)) {
                    // return the connection to the requestor 
                    return connection; 
                }
                else {
                    // remove this from the pool...it's toast. 
                    poolConnections.remove(connection); 
                    // make sure this cleans up after itself. 
                    connection.closeServerConnection(); 
                }
            }

            // we've not found something usable in the pool.  Now see if 
            // we're allowed to add another connection, or must just wait for 
            // someone else to return one. 

            if (poolConnections.size() >= poolSize) {
                // check to see if we've been told to shutdown before waiting
                if (closed) {
                    throw new StoreClosedException(store, "No Store connections available"); 
                }
                // we need to wait for somebody to return a connection 
                // once woken up, we'll spin around and try to snag one from 
                // the pool again.
                try {
                    wait(MAX_POOL_WAIT);
                } catch (InterruptedException e) {
                }
                
                // check to see if we've been told to shutdown while we waited
                if (closed) {
                    throw new StoreClosedException(store, "No Store connections available"); 
                }
            }
            else {
                // exit out and create a new connection.  Since 
                // we're going to be outside the synchronized block, it's possible 
                // we'll go over our pool limit.  We'll take care of that when connections start 
                // getting returned. 
                return null; 
            }
        }
        // we've hit the maximum number of retries...just create a new connection. 
        return null; 
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPConnectionPool.java [285:344]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    protected synchronized IMAPConnection getPoolConnection() throws MessagingException {
        // if the pool is closed, we can't process this 
        if (closed) {
            throw new StoreClosedException(store, "No Store connections available"); 
        }
        
        // we'll retry this a few times if the connection pool is full, but 
        // after that, we'll just create a new connection. 
        for (int i = 0; i < MAX_CONNECTION_RETRIES; i++) {
            Iterator it = availableConnections.iterator(); 
            while (it.hasNext()) {
                IMAPConnection connection = (IMAPConnection)it.next(); 
                // live or dead, we're going to remove this from the 
                // available list. 
                it.remove(); 
                if (connection.isAlive(poolTimeout)) {
                    // return the connection to the requestor 
                    return connection; 
                }
                else {
                    // remove this from the pool...it's toast. 
                    poolConnections.remove(connection); 
                    // make sure this cleans up after itself. 
                    connection.closeServerConnection(); 
                }
            }

            // we've not found something usable in the pool.  Now see if 
            // we're allowed to add another connection, or must just wait for 
            // someone else to return one. 

            if (poolConnections.size() >= poolSize) {
                // check to see if we've been told to shutdown before waiting
                if (closed) {
                    throw new StoreClosedException(store, "No Store connections available"); 
                }
                // we need to wait for somebody to return a connection 
                // once woken up, we'll spin around and try to snag one from 
                // the pool again.
                try {
                    wait(MAX_POOL_WAIT);
                } catch (InterruptedException e) {
                }
                
                // check to see if we've been told to shutdown while we waited
                if (closed) {
                    throw new StoreClosedException(store, "No Store connections available"); 
                }
            }
            else {
                // exit out and create a new connection.  Since 
                // we're going to be outside the synchronized block, it's possible 
                // we'll go over our pool limit.  We'll take care of that when connections start 
                // getting returned. 
                return null; 
            }
        }
        // we've hit the maximum number of retries...just create a new connection. 
        return null; 
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



geronimo-javamail_1.5/geronimo-javamail_1.5_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPConnectionPool.java [285:344]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    protected synchronized IMAPConnection getPoolConnection() throws MessagingException {
        // if the pool is closed, we can't process this 
        if (closed) {
            throw new StoreClosedException(store, "No Store connections available"); 
        }
        
        // we'll retry this a few times if the connection pool is full, but 
        // after that, we'll just create a new connection. 
        for (int i = 0; i < MAX_CONNECTION_RETRIES; i++) {
            Iterator it = availableConnections.iterator(); 
            while (it.hasNext()) {
                IMAPConnection connection = (IMAPConnection)it.next(); 
                // live or dead, we're going to remove this from the 
                // available list. 
                it.remove(); 
                if (connection.isAlive(poolTimeout)) {
                    // return the connection to the requestor 
                    return connection; 
                }
                else {
                    // remove this from the pool...it's toast. 
                    poolConnections.remove(connection); 
                    // make sure this cleans up after itself. 
                    connection.closeServerConnection(); 
                }
            }

            // we've not found something usable in the pool.  Now see if 
            // we're allowed to add another connection, or must just wait for 
            // someone else to return one. 

            if (poolConnections.size() >= poolSize) {
                // check to see if we've been told to shutdown before waiting
                if (closed) {
                    throw new StoreClosedException(store, "No Store connections available"); 
                }
                // we need to wait for somebody to return a connection 
                // once woken up, we'll spin around and try to snag one from 
                // the pool again.
                try {
                    wait(MAX_POOL_WAIT);
                } catch (InterruptedException e) {
                }
                
                // check to see if we've been told to shutdown while we waited
                if (closed) {
                    throw new StoreClosedException(store, "No Store connections available"); 
                }
            }
            else {
                // exit out and create a new connection.  Since 
                // we're going to be outside the synchronized block, it's possible 
                // we'll go over our pool limit.  We'll take care of that when connections start 
                // getting returned. 
                return null; 
            }
        }
        // we've hit the maximum number of retries...just create a new connection. 
        return null; 
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



geronimo-javamail_1.6/geronimo-javamail_1.6_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPConnectionPool.java [285:344]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    protected synchronized IMAPConnection getPoolConnection() throws MessagingException {
        // if the pool is closed, we can't process this 
        if (closed) {
            throw new StoreClosedException(store, "No Store connections available"); 
        }
        
        // we'll retry this a few times if the connection pool is full, but 
        // after that, we'll just create a new connection. 
        for (int i = 0; i < MAX_CONNECTION_RETRIES; i++) {
            Iterator it = availableConnections.iterator(); 
            while (it.hasNext()) {
                IMAPConnection connection = (IMAPConnection)it.next(); 
                // live or dead, we're going to remove this from the 
                // available list. 
                it.remove(); 
                if (connection.isAlive(poolTimeout)) {
                    // return the connection to the requestor 
                    return connection; 
                }
                else {
                    // remove this from the pool...it's toast. 
                    poolConnections.remove(connection); 
                    // make sure this cleans up after itself. 
                    connection.closeServerConnection(); 
                }
            }

            // we've not found something usable in the pool.  Now see if 
            // we're allowed to add another connection, or must just wait for 
            // someone else to return one. 

            if (poolConnections.size() >= poolSize) {
                // check to see if we've been told to shutdown before waiting
                if (closed) {
                    throw new StoreClosedException(store, "No Store connections available"); 
                }
                // we need to wait for somebody to return a connection 
                // once woken up, we'll spin around and try to snag one from 
                // the pool again.
                try {
                    wait(MAX_POOL_WAIT);
                } catch (InterruptedException e) {
                }
                
                // check to see if we've been told to shutdown while we waited
                if (closed) {
                    throw new StoreClosedException(store, "No Store connections available"); 
                }
            }
            else {
                // exit out and create a new connection.  Since 
                // we're going to be outside the synchronized block, it's possible 
                // we'll go over our pool limit.  We'll take care of that when connections start 
                // getting returned. 
                return null; 
            }
        }
        // we've hit the maximum number of retries...just create a new connection. 
        return null; 
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



