patch by sebb for
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 Aug 2009 16:10:05 +0000 (16:10 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 Aug 2009 16:10:05 +0000 (16:10 +0000)
https://issues.apache.org/bugzilla/show_bug.cgi?id=47577

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@801283 13f79535-47bb-0310-9956-ffa450edef68

modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/MultiLockFairBlockingQueue.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ProxyConnection.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/SlowQueryReport.java

index b433222..85be2f6 100644 (file)
@@ -143,10 +143,10 @@ public class ConnectionPool {
      */
     public Future<Connection> getConnectionAsync() throws SQLException {
         //we can only retrieve a future if the underlying queue supports it.
-        if (idle instanceof FairBlockingQueue) {
+        if (idle instanceof FairBlockingQueue<?>) {
             Future<PooledConnection> pcf = ((FairBlockingQueue<PooledConnection>)idle).pollAsync();
             return new ConnectionFuture(pcf);
-        } else if (idle instanceof MultiLockFairBlockingQueue) {
+        } else if (idle instanceof MultiLockFairBlockingQueue<?>) {
                 Future<PooledConnection> pcf = ((MultiLockFairBlockingQueue<PooledConnection>)idle).pollAsync();
                 return new ConnectionFuture(pcf);
         } else {
@@ -1069,6 +1069,7 @@ public class ConnectionPool {
             }
         }
 
+        @Override
         public void run() {
             while (run) {
                 try {
index ff291aa..142c5b7 100644 (file)
@@ -188,6 +188,7 @@ public class DataSourceProxy implements PoolConfiguration {
         else return p.getSize();
     }
 
+    @Override
     public String toString() {
         return super.toString()+"{"+getPoolProperties()+"}";
     }
index 5a0325c..ea56e86 100644 (file)
@@ -185,11 +185,11 @@ public class FairBlockingQueue<E> implements BlockingQueue<E> {
                 waiters.addLast(c);
                 lock.unlock();
                 //return a future that will wait for the object
-                result = new ItemFuture(c);
+                result = new ItemFuture<E>(c);
             } else {
                 lock.unlock();
                 //return a future with the item
-                result = new ItemFuture(item);
+                result = new ItemFuture<E>(item);
             }
             error = false;
         } finally {
index 1ec8064..7d37eaa 100644 (file)
@@ -196,11 +196,11 @@ public class MultiLockFairBlockingQueue<E> implements BlockingQueue<E> {
                 waiters[idx].addLast(c);
                 lock.unlock();
                 //return a future that will wait for the object
-                result = new ItemFuture(c);
+                result = new ItemFuture<E>(c);
             } else {
                 lock.unlock();
                 //return a future with the item
-                result = new ItemFuture(item);
+                result = new ItemFuture<E>(item);
             }
             error = false;
         } finally {
@@ -323,9 +323,9 @@ public class MultiLockFairBlockingQueue<E> implements BlockingQueue<E> {
      * {@inheritDoc}
      */
     public boolean addAll(Collection<? extends E> c) {
-        Iterator i = c.iterator();
+        Iterator<? extends E> i = c.iterator();
         while (i.hasNext()) {
-            E e = (E)i.next();
+            E e = i.next();
             offer(e);
         }
         return true;
index d55e766..63e6a3a 100644 (file)
@@ -651,6 +651,7 @@ public class PoolProperties implements PoolConfiguration {
         this.interceptors = null;
     }
 
+    @Override
     public String toString() {
         StringBuffer buf = new StringBuffer("ConnectionPool[");
         try {
@@ -786,9 +787,11 @@ public class PoolProperties implements PoolConfiguration {
         public String getValue() {
             return value;
         }
+        @Override
         public int hashCode() {
             return name.hashCode();
         }
+        @Override
         public boolean equals(Object o) {
             if (o==this) return true;
             if (o instanceof InterceptorProperty) {
index 8991a60..167f1ae 100644 (file)
@@ -291,7 +291,8 @@ public class PooledConnection {
      *  
      * @return true if the connection was validated successfully. It returns true even if validation was not performed, such as when 
      * {@link PoolConfiguration#setValidationInterval(long)} has been called with a positive value. 
-     * @return false if the validation failed. The caller should close the connection if false is returned since a session could have been left in 
+     * <p>
+     * false if the validation failed. The caller should close the connection if false is returned since a session could have been left in 
      * an unknown state during initialization.
      */
     public boolean validate(int validateAction,String sql) {
@@ -322,7 +323,7 @@ public class PooledConnection {
         Statement stmt = null;
         try {
             stmt = connection.createStatement();
-            boolean exec = stmt.execute(query);
+            stmt.execute(query);
             stmt.close();
             this.lastValidated = now;
             return true;
@@ -516,6 +517,7 @@ public class PooledConnection {
         this.handler = handler;
     }
     
+    @Override
     public String toString() {
         return "PooledConnection["+(connection!=null?connection.toString():"null")+"]";
     }
index f3cab3a..8357846 100644 (file)
@@ -59,6 +59,7 @@ public class ProxyConnection extends JdbcInterceptor {
         setUseEquals(useEquals);
     }
 
+    @Override
     public void reset(ConnectionPool parent, PooledConnection con) {
         this.pool = parent;
         this.connection = con;
@@ -77,6 +78,7 @@ public class ProxyConnection extends JdbcInterceptor {
         }
     }
 
+    @Override
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
         if (compare(ISCLOSED_VAL,method)) {
             return Boolean.valueOf(isClosed());
@@ -117,6 +119,7 @@ public class ProxyConnection extends JdbcInterceptor {
         return pool;
     }
     
+    @Override
     public String toString() {
         return "ProxyConnection["+(connection!=null?connection.toString():"null")+"]";
     }
index 300b815..5056778 100644 (file)
@@ -52,6 +52,7 @@ public class ConnectionState extends JdbcInterceptor  {
     protected String catalog = null;
     
     
+    @Override
     public void reset(ConnectionPool parent, PooledConnection con) {
         if (parent==null || con==null) return;
         PoolConfiguration poolProperties = parent.getPoolProperties();
index 28a71a4..82035d6 100644 (file)
@@ -287,6 +287,7 @@ public class SlowQueryReport extends AbstractQueryReport  {
             return FIELD_TYPES;
         }
         
+        @Override
         public String toString() {
             StringBuffer buf = new StringBuffer("QueryStats[query:");
             buf.append(query);
@@ -390,10 +391,12 @@ public class SlowQueryReport extends AbstractQueryReport  {
             return totalInvocationTime;
         }
 
+        @Override
         public int hashCode() {
             return query.hashCode();
         }
         
+        @Override
         public boolean equals(Object other) {
             if (other instanceof QueryStats) {
                 QueryStats qs = (QueryStats)other;