You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/09/09 13:28:43 UTC

svn commit: r1521051 - in /tomcat/tc7.0.x/trunk: ./ modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/

Author: markt
Date: Mon Sep  9 11:28:42 2013
New Revision: 1521051

URL: http://svn.apache.org/r1521051
Log:
Fix checkstyle failures
 - no License header
 - invalid (old JUnit) imports
 - trailing whitespace
 - missing @Overrides

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/mbeans-descriptors.xml
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestValidationQueryTimeout.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1521049-1521050

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java?rev=1521051&r1=1521050&r2=1521051&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java Mon Sep  9 11:28:42 2013
@@ -371,7 +371,7 @@ public class DataSourceFactory implement
         if (value != null) {
             poolProperties.setValidationQuery(value);
         }
-        
+
         value = properties.getProperty(PROP_VALIDATIONQUERY_TIMEOUT);
         if (value != null) {
             poolProperties.setValidationQueryTimeout(Integer.parseInt(value));

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java?rev=1521051&r1=1521050&r2=1521051&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java Mon Sep  9 11:28:42 2013
@@ -442,11 +442,11 @@ public class DataSourceProxy implements 
     public void setValidatorClassName(String className) {
         this.poolProperties.setValidatorClassName(className);
     }
-    
+
     /**
      * {@inheritDoc}
      */
-    
+
     @Override
     public void setValidationQueryTimeout(int validationQueryTimeout) {
         this.poolProperties.setValidationQueryTimeout(validationQueryTimeout);
@@ -927,12 +927,12 @@ public class DataSourceProxy implements 
     /**
      * {@inheritDoc}
      */
-    
+
     @Override
     public int getValidationQueryTimeout() {
         return getPoolProperties().getValidationQueryTimeout();
     }
-    
+
     /**
      * {@inheritDoc}
      */

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java?rev=1521051&r1=1521050&r2=1521051&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java Mon Sep  9 11:28:42 2013
@@ -525,17 +525,17 @@ public interface PoolConfiguration {
 
     /**
      * The timeout in seconds before a connection validation queries fail.
-     * A value less than or equal to zero will disable this feature.  Defaults to -1. 
-     * @return the timeout value in seconds 
+     * A value less than or equal to zero will disable this feature.  Defaults to -1.
+     * @return the timeout value in seconds
      */
     public int getValidationQueryTimeout();
-    
+
     /**
      * The timeout in seconds before a connection validation queries fail.
-     * A value less than or equal to zero will disable this feature.  Defaults to -1. 
+     * A value less than or equal to zero will disable this feature.  Defaults to -1.
      */
     public void setValidationQueryTimeout(int validationQueryTimeout);
-    
+
     /**
      * Return the name of the optional validator class - may be null.
      *

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java?rev=1521051&r1=1521050&r2=1521051&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java Mon Sep  9 11:28:42 2013
@@ -388,7 +388,7 @@ public class PoolProperties implements P
     public int getValidationQueryTimeout() {
         return validationQueryTimeout;
     }
-    
+
     /**
      * {@inheritDoc}
      */
@@ -396,7 +396,7 @@ public class PoolProperties implements P
     public void setValidationQueryTimeout(int validationQueryTimeout) {
         this.validationQueryTimeout = validationQueryTimeout;
     }
-    
+
     /**
      * {@inheritDoc}
      */

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java?rev=1521051&r1=1521050&r2=1521051&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java Mon Sep  9 11:28:42 2013
@@ -452,12 +452,12 @@ public class PooledConnection {
         Statement stmt = null;
         try {
             stmt = connection.createStatement();
-            
+
             int validationQueryTimeout = poolProperties.getValidationQueryTimeout();
             if (validationQueryTimeout > 0) {
                 stmt.setQueryTimeout(validationQueryTimeout);
             }
-            
+
             stmt.execute(query);
             stmt.close();
             this.lastValidated = now;

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java?rev=1521051&r1=1521050&r2=1521051&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java Mon Sep  9 11:28:42 2013
@@ -309,7 +309,7 @@ public class ConnectionPool extends Noti
     public String getValidationQuery() {
         return getPoolProperties().getValidationQuery();
     }
-    
+
     @Override
     public int getValidationQueryTimeout() {
         return getPoolProperties().getValidationQueryTimeout();
@@ -672,7 +672,7 @@ public class ConnectionPool extends Noti
     public void setValidationQueryTimeout(int validationQueryTimeout) {
         getPoolProperties().setValidationQueryTimeout(validationQueryTimeout);
     }
-    
+
     /**
      * {@inheritDoc}
      */

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/mbeans-descriptors.xml?rev=1521051&r1=1521050&r2=1521051&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/mbeans-descriptors.xml (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/mbeans-descriptors.xml Mon Sep  9 11:28:42 2013
@@ -125,7 +125,7 @@
            description="The query to run during validation"
                   type="java.lang.String"
              writeable="false"/>
-             
+
     <attribute    name="validationQueryTimeout"
            description="The timeout in seconds before a connection validation queries fail"
                   type="java.lang.Integer"

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestValidationQueryTimeout.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestValidationQueryTimeout.java?rev=1521051&r1=1521050&r2=1521051&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestValidationQueryTimeout.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestValidationQueryTimeout.java Mon Sep  9 11:28:42 2013
@@ -1,3 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
@@ -10,73 +26,74 @@ import java.sql.Statement;
 import java.util.Properties;
 import java.util.logging.Logger;
 
-import junit.framework.Assert;
-
-import org.apache.tomcat.jdbc.pool.interceptor.QueryTimeoutInterceptor;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import org.apache.tomcat.jdbc.pool.interceptor.QueryTimeoutInterceptor;
+
 public class TestValidationQueryTimeout extends DefaultTestCase {
-    
+
     private static int TIMEOUT = 10;
     private static boolean isTimeoutSet;
     private static final String longQuery = "select * from test as A, test as B, test as C, test as D, test as E";
-    
+
     @Before
     public void setUp() throws SQLException {
         DriverManager.registerDriver(new MockDriver());
-        
+
         // use our mock driver
         this.datasource.setDriverClassName(MockDriver.class.getName());
         this.datasource.setUrl(MockDriver.url);
-        
-        // Required to trigger validation query's execution 
+
+        // Required to trigger validation query's execution
         this.datasource.setInitialSize(1);
         this.datasource.setTestOnBorrow(true);
         this.datasource.setValidationInterval(-1);
         this.datasource.setValidationQuery("SELECT 1");
         this.datasource.setValidationQueryTimeout(TIMEOUT);
-        
+
         TIMEOUT = 10;
         isTimeoutSet = false;
     }
-    
+
+    @Override
     @After
     public void tearDown() throws SQLException {
         DriverManager.deregisterDriver(new MockDriver());
     }
-    
+
     @Test
     public void testValidationQueryTimeoutEnabled() throws Exception {
         // because testOnBorrow is true, this triggers the validation query
         this.datasource.getConnection();
         Assert.assertTrue(isTimeoutSet);
     }
-    
+
     @Test
     public void testValidationQueryTimeoutDisabled() throws Exception {
         this.datasource.setValidationQueryTimeout(-1);
-        
+
         // because testOnBorrow is true, this triggers the validation query
         this.datasource.getConnection();
         Assert.assertFalse(isTimeoutSet);
     }
-    
+
     @Test
     public void testValidationQueryTimeoutWithQueryTimeoutInterceptor() throws Exception {
         int interceptorTimeout = 30;
         this.datasource.setJdbcInterceptors(
                             QueryTimeoutInterceptor.class.getName()+
                             "(queryTimeout="+ interceptorTimeout +")");
-        
+
         // because testOnBorrow is true, this triggers the validation query
         Connection con = this.datasource.getConnection();
         Assert.assertTrue(isTimeoutSet);
-        
+
         // increase the expected timeout to 30, which is what we set for the interceptor
         TIMEOUT = 30;
-        
+
         // now create a statement, make sure the query timeout is set by the interceptor
         Statement st = con.createStatement();
         Assert.assertEquals(interceptorTimeout, st.getQueryTimeout());
@@ -88,49 +105,49 @@ public class TestValidationQueryTimeout 
         Assert.assertEquals(interceptorTimeout, st.getQueryTimeout());
         st.close();
         con.close();
-        
+
         // pull another connection and check it
         TIMEOUT = 10;
         isTimeoutSet = false;
         this.datasource.getConnection();
         Assert.assertTrue(isTimeoutSet);
     }
-    
+
     // this test depends on the execution time of the validation query
     //   specifically, it needs to run for longer than 1 second to pass
     //   if this fails
-    @Test(expected=SQLException.class) 
+    @Test(expected=SQLException.class)
     public void testValidationQueryTimeoutOnConnection() throws Exception {
         // use our mock driver
         this.datasource.setDriverClassName("org.h2.Driver");
         this.datasource.setUrl("jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE");
-        
-        // Required to trigger validation query's execution 
+
+        // Required to trigger validation query's execution
         this.datasource.setTestOnConnect(true);
         this.datasource.setValidationInterval(-1);
         this.datasource.setValidationQuery(longQuery);
         this.datasource.setValidationQueryTimeout(1);
-        
+
         this.datasource.getConnection();
     }
-    
+
     @Test(expected=SQLException.class)
     public void testValidationInvalidOnConnection() throws Exception {
         // use our mock driver
         this.datasource.setDriverClassName("org.h2.Driver");
         this.datasource.setUrl("jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE");
-        
-        // Required to trigger validation query's execution 
+
+        // Required to trigger validation query's execution
         this.datasource.setTestOnBorrow(true);
         this.datasource.setInitialSize(1);
         this.datasource.setTestOnConnect(true);
         this.datasource.setValidationInterval(-1);
         this.datasource.setValidationQuery("SELECT");
         this.datasource.setValidationQueryTimeout(1);
-        
+
         this.datasource.getConnection();
     }
-    
+
     @Test
     public void testLongValidationQueryTime() throws Exception {
         // use our mock driver
@@ -151,27 +168,27 @@ public class TestValidationQueryTimeout 
         } catch (SQLException ex) {}
         finally {
             end = System.currentTimeMillis();
-        
+
             if (stmt != null) { stmt.close(); }
             if (con != null) { con.close(); }
-            
+
             Assert.assertTrue(start != 0 && end != 0);
             Assert.assertTrue((end - start) > 1000);
         }
     }
-    
+
     @Test
     public void testValidationQueryTimeoutOnBorrow() throws Exception {
         // use our mock driver
         this.datasource.setDriverClassName("org.h2.Driver");
         this.datasource.setUrl("jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE");
-        
-        // Required to trigger validation query's execution 
+
+        // Required to trigger validation query's execution
         this.datasource.setTestOnBorrow(true);
         this.datasource.setValidationInterval(-1);
         this.datasource.setValidationQuery(longQuery);
         this.datasource.setValidationQueryTimeout(1);
-        
+
         // assert that even though the validation query times out, we still get a connection
         Connection con = this.datasource.getConnection();
         Assert.assertNotNull(con);
@@ -181,7 +198,7 @@ public class TestValidationQueryTimeout 
         st.close();
         con.close();
     }
-    
+
     /**
      * Mock Driver, Connection and Statement implementations use to verify setQueryTimeout was called.
      */
@@ -226,7 +243,7 @@ public class TestValidationQueryTimeout 
             return null;
         }
     }
-    
+
     public static class MockConnection extends org.apache.tomcat.jdbc.test.driver.Connection {
         public MockConnection(Properties info) {
             super(info);
@@ -237,7 +254,7 @@ public class TestValidationQueryTimeout 
             return new MockStatement();
         }
     }
-    
+
     public static class MockStatement extends org.apache.tomcat.jdbc.test.driver.Statement {
         @Override
         public void setQueryTimeout(int seconds) throws SQLException {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org