Bugs item #846551, was opened at 2003-11-21 12:45 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=376685&aid=846551&group_id=22866
Category: JBossCX Group: v3.2 Status: Open Resolution: None Priority: 5 Submitted By: Walter McConnell (waltermcconnell) Assigned to: Nobody/Anonymous (nobody) Summary: expn in getConneciton makes pool count wrong Initial Comment: Red Hat 9 (2.4.20-6) JDK 1.4.1_02 When a ResourceException is thrown from within the getConnection method of a ManagedConnection, the pool count becomes wrong. This happens because while a permit is accepted in InternalManagedConnecitonPool.getConnection() it is never released in the case of an error. BaseConnectionManager2 will never call returnConnection on the connection manager in the case that ManagedConnection.getConnecion() fails .. its easy to reproduce .. just add this unit test to BaseConnectionManagerUnitTestCase ... in order to get the test to fail you will need to temporarily get the TestManagedConnection to throw an exception in its getConnecion method .. public void testExceptionInGetConnectionLeavesPoolCountWrong() throws Exception { InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams(); pp.minSize = 0; pp.maxSize = 5; pp.blockingTimeout = 100; pp.idleTimeout = 500; ManagedConnectionFactory mcf = new TestManagedConnectionFactory(); ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.OnePool(mcf, pp, log); BaseConnectionManager2 cm = new NoTxConnectionManager(ccm, poolingStrategy); try{ Object mc = cm.allocateConnection(mcf, null); } catch(Exception thrown) { System.err.println("Caught Exception " + thrown.toString()); } assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == 0); } the fix seems pretty trivial too ... In BaseConnectionManager2.allocateConnection() [line 473], just wrap the call to mc.getConnection() with a try/catch .. if it throws a ResoruceException then tell the pooling strategy to return the connection, killing it. Then re-throw the exception. BaseConnectionManager2.java [Line 491 ....] try { Object connection = mc.getConnection(subject, cri); registerAssociation(mc, connection); if (ccm != null) { ccm.registerConnection(this, new ConnectionRecord(mc, connection, cri)); } // end of if () return connection; } catch(ResourceException thrown) { poolingStrategy.returnConnection(mc, true); throw thrown; } I've also attached a test rar and a web app that will show the problem in a running JBoss server .. after deploying the lot into the deploy directory, then keep an eye on the "AvailableConnectionCount" in the ManagedConnectionPools MBean view .. you will see it dropping towards 0 as you refresh the http://localhost:8080/testwar page .. this is obviously incorrect as when it hits 0, the pool will refuse connections and the JBoss pool manager will blow .. cheers, Walter McConnell. IONA Technologies. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=376685&aid=846551&group_id=22866 ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ JBoss-Development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development