You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2012/08/07 02:56:00 UTC

svn commit: r1370089 - in /manifoldcf/trunk: ./ connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/ framework/core/src/main/java/org/apache/manifoldcf/core/database/ framework/core/src/main/java/org/apache...

Author: kwright
Date: Tue Aug  7 00:56:00 2012
New Revision: 1370089

URL: http://svn.apache.org/viewvc?rev=1370089&view=rev
Log:
Fix for CONNECTORS-500.

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java
    manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/ConnectionFactory.java
    manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/ConnectionPool.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1370089&r1=1370088&r2=1370089&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Tue Aug  7 00:56:00 2012
@@ -3,6 +3,13 @@ $Id$
 
 ======================= 0.7-dev =====================
 
+CONNECTORS-500: Tests were hanging or otherwise doing strange
+things on exit.  This was because the connection pool was being
+closed when the web application(s) were being unloaded, meaning
+that cleanup of the database took place with the pool in an
+inconsistent state.
+(Karl Wright)
+
 CONNECTORS-494: Fix the build to conditionally include registration
 commands for connectors that are built with stubs.
 (Shinichiro Abe, Karl Wright)

Modified: manifoldcf/trunk/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java?rev=1370089&r1=1370088&r2=1370089&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java (original)
+++ manifoldcf/trunk/connectors/sharepoint/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/sharepoint/XMLGenTest.java Tue Aug  7 00:56:00 2012
@@ -39,7 +39,7 @@ public class XMLGenTest
     throws Exception
   {
     String pagingXML = SPSProxyHelper.buildPagingQueryOptions("some next string").get_any()[0].toString();
-    assertEquals("<QueryOptions><Paging ListItemCollectionPositionNext=\"some next string\"/></QueryOptions>",pagingXML);
+    assertEquals("<QueryOptions><Paging ListItemCollectionPositionNext=\"some next string\"/><ViewAttributes Scope=\"Recursive\"/></QueryOptions>",pagingXML);
   }
   
   @Test

Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/ConnectionFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/ConnectionFactory.java?rev=1370089&r1=1370088&r2=1370089&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/ConnectionFactory.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/ConnectionFactory.java Tue Aug  7 00:56:00 2012
@@ -191,17 +191,20 @@ public class ConnectionFactory
 
     public void releaseAll()
     {
+      ConnectionPoolManager thisPool;
       synchronized (poolExistenceLock)
       {
         if (_pool == null)
           return;
+        thisPool = _pool;
+        _pool = null;
       }
 
       // Cleanup strategy: Some connections are still in use because they are being
       // used by non-worker threads that have been interrupted but haven't yet died.
       // Cleaning these up is a challenge.  For now I won't address this.
       
-      _pool.shutdown();
+      thisPool.shutdown();
     }
       
       /*

Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/ConnectionPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/ConnectionPool.java?rev=1370089&r1=1370088&r2=1370089&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/ConnectionPool.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/jdbcpool/ConnectionPool.java Tue Aug  7 00:56:00 2012
@@ -35,6 +35,7 @@ public class ConnectionPool
   protected String password;
   protected volatile int freePointer;
   protected volatile int activeConnections;
+  protected volatile boolean closed;
   protected Connection[] freeConnections;
   protected long[] connectionCleanupTimeouts;
   protected long expiration;
@@ -49,6 +50,7 @@ public class ConnectionPool
     this.connectionCleanupTimeouts = new long[maxConnections];
     this.freePointer = 0;
     this.activeConnections = 0;
+    this.closed = false;
     this.expiration = expiration;
   }
   
@@ -66,6 +68,8 @@ public class ConnectionPool
       {
         if (freePointer > 0)
         {
+          if (closed)
+            throw new InterruptedException("Pool already closed");
           Connection rval = freeConnections[--freePointer];
           freeConnections[freePointer] = null;
           return new WrappedConnection(this,rval);
@@ -116,6 +120,8 @@ public class ConnectionPool
       freeConnections[i] = null;
     }
     freePointer = 0;
+    closed = true;
+    notifyAll();
   }
   
   /** Clean up expired connections.

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java?rev=1370089&r1=1370088&r2=1370089&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java Tue Aug  7 00:56:00 2012
@@ -212,6 +212,17 @@ public class BaseITDerby extends Connect
         if (currentException == null)
           currentException = e;
       }
+      // Last, shut down the web applications.
+      // If this is done too soon it closes the database before the rest of the cleanup happens.
+      try
+      {
+        mcfInstance.unload();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
       if (currentException != null)
         throw currentException;
     }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java?rev=1370089&r1=1370088&r2=1370089&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java Tue Aug  7 00:56:00 2012
@@ -212,6 +212,17 @@ public class BaseITHSQLDB extends Connec
         if (currentException == null)
           currentException = e;
       }
+      // Last, shut down the web applications.
+      // If this is done too soon it closes the database before the rest of the cleanup happens.
+      try
+      {
+        mcfInstance.unload();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
       if (currentException != null)
         throw currentException;
     }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java?rev=1370089&r1=1370088&r2=1370089&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java Tue Aug  7 00:56:00 2012
@@ -212,6 +212,17 @@ public class BaseITMySQL extends Connect
         if (currentException == null)
           currentException = e;
       }
+      // Last, shut down the web applications.
+      // If this is done too soon it closes the database before the rest of the cleanup happens.
+      try
+      {
+        mcfInstance.unload();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
       if (currentException != null)
         throw currentException;
     }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java?rev=1370089&r1=1370088&r2=1370089&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java Tue Aug  7 00:56:00 2012
@@ -212,6 +212,17 @@ public class BaseITPostgresql extends Co
         if (currentException == null)
           currentException = e;
       }
+      // Last, shut down the web applications.
+      // If this is done too soon it closes the database before the rest of the cleanup happens.
+      try
+      {
+        mcfInstance.unload();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
       if (currentException != null)
         throw currentException;
     }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java?rev=1370089&r1=1370088&r2=1370089&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java Tue Aug  7 00:56:00 2012
@@ -548,15 +548,21 @@ public class ManifoldCFInstance
         currentException = e;
     }
       
+    if (currentException != null)
+      throw currentException;
+  }
+  
+  public void unload()
+    throws Exception
+  {
     if (server != null)
     {
+      // Unfortunately, this causes the shutdown hooks to be called, which causes
+      // no end of trouble unless it is done last.
       server.stop();
       server.join();
       server = null;
     }
-      
-    if (currentException != null)
-      throw currentException;
   }
   
   protected static class DaemonThread extends Thread