You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kf...@apache.org on 2016/08/03 09:40:13 UTC

svn commit: r1755059 - in /tomcat/tc8.0.x/trunk: modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java webapps/docs/changelog.xml

Author: kfujino
Date: Wed Aug  3 09:40:13 2016
New Revision: 1755059

URL: http://svn.apache.org/viewvc?rev=1755059&view=rev
Log:
Ensure that the ResultSet is returned as Proxy object when enabling the StatementDecoratorInterceptor.

Modified:
    tomcat/tc8.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java
    tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc8.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java?rev=1755059&r1=1755058&r2=1755059&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java (original)
+++ tomcat/tc8.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java Wed Aug  3 09:40:13 2016
@@ -40,7 +40,11 @@ public class StatementDecoratorIntercept
 
     private static final Log logger = LogFactory.getLog(StatementDecoratorInterceptor.class);
 
-    private static final String[] EXECUTE_QUERY_TYPES = { "executeQuery" };
+    protected static final String EXECUTE_QUERY  = "executeQuery";
+    protected static final String GETGENERATEDKEYS = "getGeneratedKeys";
+    protected static final String GET_RESULTSET  = "getResultSet";
+
+    protected static final String[] RESULTSET_TYPES = {EXECUTE_QUERY, GETGENERATEDKEYS, GET_RESULTSET};
 
     /**
      * the constructors that are used to create statement proxies
@@ -154,13 +158,17 @@ public class StatementDecoratorIntercept
     }
 
     protected boolean isExecuteQuery(String methodName) {
-        return EXECUTE_QUERY_TYPES[0].equals(methodName);
+        return EXECUTE_QUERY.equals(methodName);
     }
 
     protected boolean isExecuteQuery(Method method) {
         return isExecuteQuery(method.getName());
     }
 
+    protected boolean isResultSet(Method method, boolean process) {
+        return process(RESULTSET_TYPES, method, process);
+    }
+
     /**
      * Class to measure query execute time.
      */
@@ -236,7 +244,8 @@ public class StatementDecoratorIntercept
             if (compare(GETCONNECTION_VAL,method)){
                 return connection;
             }
-            boolean process = isExecuteQuery(method);
+            boolean process = false;
+            process = isResultSet(method, process);
             // check to see if we are about to execute a query
             // if we are executing, get the current time
             Object result = null;
@@ -256,7 +265,7 @@ public class StatementDecoratorIntercept
                     throw t;
                 }
             }
-            if (process){
+            if (process && result != null) {
                 Constructor<?> cons = getResultSetConstructor();
                 result = cons.newInstance(new Object[]{new ResultSetProxy(actualProxy, result)});
             }

Modified: tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml?rev=1755059&r1=1755058&r2=1755059&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml Wed Aug  3 09:40:13 2016
@@ -240,6 +240,10 @@
         that continues to return an invalid connection after database restart.
         (kfujino)
       </fix>
+      <fix>
+        Ensure that the <code>ResultSet</code> is returned as Proxy object when
+        enabling the <code>StatementDecoratorInterceptor</code>. (kfujino)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Other">



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