try {
if (!pool.isEmpty()) {
ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
ManagedConnectionFactory managedConnectionFactory = mci.getManagedConnectionFactory();
ManagedConnection matchedMC =
managedConnectionFactory
.matchManagedConnections(pool.keySet(),
mci.getSubject(),
mci.getConnectionRequestInfo());
if (matchedMC != null) {
connectionInfo.setManagedConnectionInfo((ManagedConnectionInfo) pool.get(matchedMC));