manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1437095 - in /manifoldcf/branches/release-1.1-branch: ./ connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/
Date Tue, 22 Jan 2013 18:48:46 GMT
Author: kwright
Date: Tue Jan 22 18:48:45 2013
New Revision: 1437095

URL: http://svn.apache.org/viewvc?rev=1437095&view=rev
Log:
Pull up fix for CONNECTORS-620 from trunk.

Modified:
    manifoldcf/branches/release-1.1-branch/   (props changed)
    manifoldcf/branches/release-1.1-branch/CHANGES.txt
    manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnection.java
    manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnectionFactory.java
    manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java

Propchange: manifoldcf/branches/release-1.1-branch/
------------------------------------------------------------------------------
  Merged /manifoldcf/trunk:r1437093

Modified: manifoldcf/branches/release-1.1-branch/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/CHANGES.txt?rev=1437095&r1=1437094&r2=1437095&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/CHANGES.txt (original)
+++ manifoldcf/branches/release-1.1-branch/CHANGES.txt Tue Jan 22 18:48:45 2013
@@ -3,6 +3,10 @@ $Id$
 
 ======================= Release 1.1 =====================
 
+CONNECTORS-620: It was possible for the JDBC Connector to leak
+JDBC connections under some error conditions.
+(Anthony Leonard, Karl Wright)
+
 CONNECTORS-619: Include slf4j jars in multiprocess agents classpath.
 This was causing Solrj to not work on multiprocess deployments.
 (Erlend Garåsen, Karl Wright) 

Modified: manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnection.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnection.java?rev=1437095&r1=1437094&r2=1437095&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnection.java
(original)
+++ manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnection.java
Tue Jan 22 18:48:45 2013
@@ -863,45 +863,79 @@ public class JDBCConnection
       throws ManifoldCFException, ServiceInterruption
     {
       ManifoldCFException rval = null;
+      Error error = null;
+      RuntimeException rtException = null;
       if (rs != null)
       {
         try
         {
           closeResultset(rs);
-          rs = null;
         }
         catch (ManifoldCFException e)
         {
           if (rval == null || e.getErrorCode() == ManifoldCFException.INTERRUPTED)
             rval = e;
         }
+        catch (Error e)
+        {
+          error = e;
+        }
+        catch (RuntimeException e)
+        {
+          rtException = e;
+        }
+        finally
+        {
+          rs = null;
+        }
       }
       if (stmt != null)
       {
         try
         {
           closeStmt(stmt);
-          stmt = null;
         }
         catch (ManifoldCFException e)
         {
           if (rval == null || e.getErrorCode() == ManifoldCFException.INTERRUPTED)
             rval = e;
         }
+        catch (Error e)
+        {
+          error = e;
+        }
+        catch (RuntimeException e)
+        {
+          rtException = e;
+        }
+        finally
+        {
+          stmt = null;
+        }
       }
       if (connection != null)
       {
         try
         {
           JDBCConnectionFactory.releaseConnection(connection);
-          connection = null;
         }
-        catch (ManifoldCFException e)
+        catch (Error e)
         {
-          if (rval == null || e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-            rval = e;
+          error = e;
+        }
+        catch (RuntimeException e)
+        {
+          rtException = e;
+        }
+        finally
+        {
+          connection = null;
         }
       }
+      if (error != null)
+        throw error;
+      if (rtException != null)
+        throw rtException;
       if (rval != null)
         throw rval;
     }
@@ -947,15 +981,17 @@ public class JDBCConnection
           {
             closeResultset(rs);
           }
-          catch (ServiceInterruption e2)
-          {
-          }
           catch (ManifoldCFException e2)
           {
             if (e2.getErrorCode() == ManifoldCFException.INTERRUPTED)
               this.exception = e2;
             // Ignore
           }
+          catch (Throwable e2)
+          {
+            // We already have an exception to report.
+            // Eat any other exceptions from closing
+          }
           finally
           {
             rs = null;
@@ -967,15 +1003,17 @@ public class JDBCConnection
           {
             closeStmt(stmt);
           }
-          catch (ServiceInterruption e2)
-          {
-          }
           catch (ManifoldCFException e2)
           {
             if (e2.getErrorCode() == ManifoldCFException.INTERRUPTED)
               this.exception = e2;
             // Ignore
           }
+          catch (Throwable e2)
+          {
+            // We already have an exception to report.
+            // Eat any other exceptions from closing statements
+          }
           finally
           {
             stmt = null;
@@ -983,23 +1021,8 @@ public class JDBCConnection
         }
         if (connection != null)
         {
-          try
-          {
-            JDBCConnectionFactory.releaseConnection(connection);
-          }
-          catch (ServiceInterruption e2)
-          {
-          }
-          catch (ManifoldCFException e2)
-          {
-            if (e2.getErrorCode() == ManifoldCFException.INTERRUPTED)
-              this.exception = e2;
-            // Otherwise, ignore
-          }
-          finally
-          {
-            connection = null;
-          }
+          JDBCConnectionFactory.releaseConnection(connection);
+          connection = null;
         }
       }
     }
@@ -1108,6 +1131,8 @@ public class JDBCConnection
       throws ManifoldCFException, ServiceInterruption
     {
       ManifoldCFException rval = null;
+      Error error = null;
+      RuntimeException rtException = null;
       if (rs != null)
       {
         try
@@ -1122,6 +1147,14 @@ public class JDBCConnection
           if (rval == null || e.getErrorCode() == ManifoldCFException.INTERRUPTED)
             rval = e;
         }
+        catch (Error e)
+        {
+          error = e;
+        }
+        catch (RuntimeException e)
+        {
+          rtException = e;
+        }
         finally
         {
           rs = null;
@@ -1141,6 +1174,14 @@ public class JDBCConnection
           if (rval == null || e.getErrorCode() == ManifoldCFException.INTERRUPTED)
             rval = e;
         }
+        catch (Error e)
+        {
+          error = e;
+        }
+        catch (RuntimeException e)
+        {
+          rtException = e;
+        }
         finally
         {
           ps = null;
@@ -1152,13 +1193,13 @@ public class JDBCConnection
         {
           JDBCConnectionFactory.releaseConnection(connection);
         }
-        catch (ServiceInterruption e)
+        catch (Error e)
         {
+          error = e;
         }
-        catch (ManifoldCFException e)
+        catch (RuntimeException e)
         {
-          if (rval == null || e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-            rval = e;
+          rtException = e;
         }
         finally
         {
@@ -1170,14 +1211,29 @@ public class JDBCConnection
         try
         {
           cleanupParameters(params);
-          params = null;
         }
         catch (ManifoldCFException e)
         {
           if (rval == null || e.getErrorCode() == ManifoldCFException.INTERRUPTED)
             rval = e;
         }
+        catch (Error e)
+        {
+          error = e;
+        }
+        catch (RuntimeException e)
+        {
+          rtException = e;
+        }
+        finally
+        {
+          params = null;
+        }
       }
+      if (error != null)
+        throw error;
+      if (rtException != null)
+        throw rtException;
       if (rval != null)
         throw rval;
 
@@ -1225,14 +1281,14 @@ public class JDBCConnection
           {
             closeResultset(rs);
           }
-          catch (ServiceInterruption e2)
-          {
-          }
           catch (ManifoldCFException e2)
           {
             if (e2.getErrorCode() == ManifoldCFException.INTERRUPTED)
               this.exception = e2;
           }
+          catch (Throwable e2)
+          {
+          }
           finally
           {
             rs = null;
@@ -1244,14 +1300,14 @@ public class JDBCConnection
           {
             closePS(ps);
           }
-          catch (ServiceInterruption e2)
-          {
-          }
           catch (ManifoldCFException e2)
           {
             if (e2.getErrorCode() == ManifoldCFException.INTERRUPTED)
               this.exception = e2;
           }
+          catch (Throwable e2)
+          {
+          }
           finally
           {
             ps = null;
@@ -1259,22 +1315,8 @@ public class JDBCConnection
         }
         if (connection != null)
         {
-          try
-          {
-            JDBCConnectionFactory.releaseConnection(connection);
-          }
-          catch (ServiceInterruption e2)
-          {
-          }
-          catch (ManifoldCFException e2)
-          {
-            if (e2.getErrorCode() == ManifoldCFException.INTERRUPTED)
-              this.exception = e2;
-          }
-          finally
-          {
-            connection = null;
-          }
+          JDBCConnectionFactory.releaseConnection(connection);
+          connection = null;
         }
       }
     }

Modified: manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnectionFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnectionFactory.java?rev=1437095&r1=1437094&r2=1437095&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnectionFactory.java
(original)
+++ manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnectionFactory.java
Tue Jan 22 18:48:45 2013
@@ -173,7 +173,6 @@ public class JDBCConnectionFactory
   }
 
   public static void releaseConnection(WrappedConnection c)
-    throws ManifoldCFException, ServiceInterruption
   {
     c.release();
   }

Modified: manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java?rev=1437095&r1=1437094&r2=1437095&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java
(original)
+++ manifoldcf/branches/release-1.1-branch/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java
Tue Jan 22 18:48:45 2013
@@ -241,6 +241,8 @@ public class JDBCConnector extends org.a
 
     String queryText = sb.toString();
     long startQueryTime = System.currentTimeMillis();
+    // Contract for IDynamicResultset indicates that if successfully obtained, it MUST
+    // be closed.
     try
     {
       idSet = connection.executeUncachedQuery(queryText,paramList,-1);
@@ -357,6 +359,8 @@ public class JDBCConnector extends org.a
     IDynamicResultSet result;
     String queryText = sb.toString();
     long startTime = System.currentTimeMillis();
+    // Get a dynamic resultset.  Contract for dynamic resultset is that if
+    // one is returned, it MUST be closed, or a connection will leak.
     try
     {
       result = connection.executeUncachedQuery(queryText,paramList,-1);
@@ -368,11 +372,11 @@ public class JDBCConnector extends org.a
         createQueryString(queryText,paramList), "ERROR", e.getMessage(), null);
       throw e;
     }
-    // If success, record that too.
-    activities.recordActivity(new Long(startTime), ACTIVITY_EXTERNAL_QUERY, null,
-      createQueryString(queryText,paramList), "OK", null, null);
     try
     {
+      // If success, record that too.
+      activities.recordActivity(new Long(startTime), ACTIVITY_EXTERNAL_QUERY, null,
+        createQueryString(queryText,paramList), "OK", null, null);
       // Now, go through resultset
       while (true)
       {
@@ -471,6 +475,8 @@ public class JDBCConnector extends org.a
     IDynamicResultSet result;
     String queryText = sb.toString();
     long startTime = System.currentTimeMillis();
+    // Get a dynamic resultset.  Contract for dynamic resultset is that if
+    // one is returned, it MUST be closed, or a connection will leak.
     try
     {
       result = connection.executeUncachedQuery(queryText,paramList,-1);
@@ -482,12 +488,12 @@ public class JDBCConnector extends org.a
         createQueryString(queryText,paramList), "ERROR", e.getMessage(), null);
       throw e;
     }
-    // If success, record that too.
-    activities.recordActivity(new Long(startTime), ACTIVITY_EXTERNAL_QUERY, null,
-      createQueryString(queryText,paramList), "OK", null, null);
-
     try
     {
+      // If success, record that too.
+      activities.recordActivity(new Long(startTime), ACTIVITY_EXTERNAL_QUERY, null,
+        createQueryString(queryText,paramList), "OK", null, null);
+
       while (true)
       {
         IResultRow row = result.getNextRow();



Mime
View raw message