From: fhanik Date: Thu, 11 Dec 2008 22:17:02 +0000 (+0000) Subject: Implement startPool method to inform interceptors that pool is started X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=cf1cbbac282410705032b99fb0bc70aba23f0c8c;p=tomcat7.0 Implement startPool method to inform interceptors that pool is started git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@725838 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java b/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java index 6e41ed7cf..51130344c 100644 --- a/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java +++ b/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java @@ -307,7 +307,7 @@ public class ConnectionPool { * @param properties PoolProperties - properties used to initialize the pool with * @throws SQLException */ - protected void init (PoolProperties properties) throws SQLException { + protected void init(PoolProperties properties) throws SQLException { poolProperties = properties; //make space for 10 extra in case we flow over a bit busy = new ArrayBlockingQueue(properties.getMaxActive(),false); @@ -343,6 +343,16 @@ public class ConnectionPool { } + PoolProperties.InterceptorDefinition[] proxies = getPoolProperties().getJdbcInterceptorsAsArray(); + for (int i=0; iThis method is only invoked on a single instance of the interceptor, and not on every instance created. + * @param pool - the pool that is being closed. + */ + public void poolStarted(ConnectionPool pool) { + } + } diff --git a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java index 547ab0879..82ffe15c5 100644 --- a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java +++ b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java @@ -15,7 +15,6 @@ public class TestSlowQueryReport extends DefaultTestCase { public TestSlowQueryReport(String name) { super(name); } - public void testSlowSql() throws Exception { int count = 3; @@ -81,4 +80,36 @@ public class TestSlowQueryReport extends DefaultTestCase { assertNull(SlowQueryReport.getPoolStats(pool.getName())); } + public void testFailedSql() throws Exception { + int count = 3; + this.init(); + this.datasource.setMaxActive(1); + this.datasource.setJdbcInterceptors(SlowQueryReport.class.getName()); + Connection con = this.datasource.getConnection(); + String slowSql = "select 1 from non_existent"; + int exceptionCount = 0; + for (int i=0; i map = SlowQueryReport.getPoolStats(datasource.getPool().getName()); + assertNotNull(map); + assertEquals(1,map.size()); + ConnectionPool pool = datasource.getPool(); + String key = map.keySet().iterator().next(); + SlowQueryReport.QueryStats stats = map.get(key); + System.out.println("Stats:"+stats); + con.close(); + tearDown(); + assertNull(SlowQueryReport.getPoolStats(pool.getName())); + } + + }