/* 604 */ Object key = getKey(subject, cri, separateNoTx);
/* 605 */ JBossManagedConnectionPool.SubPoolContext subPool = getSubPool(key, subject, cri);
/* */
/* 607 */ InternalManagedConnectionPool mcp = subPool.getSubPool();
/* */
/* 610 */ TransactionLocal trackByTx = subPool.getTrackByTx();
/* */
/* 613 */ if ((trackByTransaction == null) || (trackByTx == null))
/* */ {
/* 615 */ ConnectionListener cl = mcp.getConnection(subject, cri);
/* 616 */ if (this.traceEnabled)
/* 617 */ dump("Got connection from pool " + cl);
/* 618 */ return cl;
/* */ }
/* */
/* */ try
/* */ {
/* 624 */ trackByTx.lock(trackByTransaction);
/* */ }
/* */ catch (Throwable t)
/* */ {
/* 628 */ JBossResourceException.rethrowAsResourceException("Unable to get connection from the pool for tx=" + trackByTransaction, t);
/* */ }
/* */
/* */ try
/* */ {
/* 633 */ ConnectionListener cl = (ConnectionListener)trackByTx.get(trackByTransaction);
/* 634 */ if (cl != null)
/* */ {
/* 636 */ if (this.traceEnabled)
/* 637 */ dump("Previous connection tracked by transaction " + cl + " tx=" + trackByTransaction);
/* 638 */ ConnectionListener localConnectionListener1 = cl;
/* */ return localConnectionListener1;
/* */ } } finally { trackByTx.unlock(trackByTransaction);
/* */ }
/* */
/* 652 */ ConnectionListener cl = mcp.getConnection(subject, cri);
/* 653 */ if (this.traceEnabled) {
/* 654 */ dump("Got connection from pool tracked by transaction " + cl + " tx=" + trackByTransaction);
/* */ }
/* */
/* */ try
/* */ {
/* 659 */ trackByTx.lock(trackByTransaction);
/* */ }
/* */ catch (Throwable t)
/* */ {
/* 663 */ mcp.returnConnection(cl, false);
/* 664 */ if (this.traceEnabled)
/* 665 */ dump("Had to return connection tracked by transaction " + cl + " tx=" + trackByTransaction + " error=" + t.getMessage());
/* 666 */ JBossResourceException.rethrowAsResourceException("Unable to get connection from the pool for tx=" + trackByTransaction, t);
/* */ }
/* */
/* */ try
/* */ {
/* 671 */ ConnectionListener other = (ConnectionListener)trackByTx.get(trackByTransaction);
/* 672 */ if (other != null)
/* */ {
/* 674 */ mcp.returnConnection(cl, false);
/* 675 */ if (this.traceEnabled)
/* 676 */ dump("Another thread already got a connection tracked by transaction " + other + " tx=" + trackByTransaction);
/* 677 */ localConnectionListener2 = other;
/* */ return localConnectionListener2;
/* */ }
/* 681 */ cl.setTrackByTx(true);
/* 682 */ trackByTx.set(cl);
/* 683 */ if (this.traceEnabled)
/* 684 */ dump("Using connection from pool tracked by transaction " + cl + " tx=" + trackByTransaction);
/* 685 */ ConnectionListener localConnectionListener2 = cl;
/* */ return localConnectionListener2; } finally { trackByTx.unlock(trackByTransaction); } throw localObject2;
/* */ }