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 2011/10/07 16:04:42 UTC

svn commit: r1180045 - in /incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki: PageBuffer.java WikiConnector.java

Author: kwright
Date: Fri Oct  7 14:04:41 2011
New Revision: 1180045

URL: http://svn.apache.org/viewvc?rev=1180045&view=rev
Log:
Add the ability to abandon a PageBuffer object, since otherwise it would be possible to have a stuck child thread forever in the case of a parent thread throwing an exception.

Modified:
    incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/PageBuffer.java
    incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java

Modified: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/PageBuffer.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/PageBuffer.java?rev=1180045&r1=1180044&r2=1180045&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/PageBuffer.java (original)
+++ incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/PageBuffer.java Fri Oct  7 14:04:41 2011
@@ -28,6 +28,7 @@ public class PageBuffer
   protected List<String> buffer = new ArrayList<String>(MAX_SIZE);
   
   protected boolean complete = false;
+  protected boolean abandoned = false;
   
   /** Constructor */
   public PageBuffer()
@@ -38,13 +39,23 @@ public class PageBuffer
   public synchronized void add(String pageID)
     throws InterruptedException
   {
-    while (buffer.size() == MAX_SIZE)
+    while (buffer.size() == MAX_SIZE && !abandoned)
       wait();
+    if (abandoned)
+      return;
     buffer.add(pageID);
     // Notify threads that are waiting on there being stuff in the queue
     notifyAll();
   }
   
+  /** Signal that the buffer should be abandoned */
+  public synchronized void abandon()
+  {
+    abandoned = true;
+    // Notify waiting threads
+    notifyAll();
+  }
+  
   /** Signal that the operation is complete, and that no more pageID's
   * will be added.
   */

Modified: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java?rev=1180045&r1=1180044&r2=1180045&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java (original)
+++ incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java Fri Oct  7 14:04:41 2011
@@ -1033,6 +1033,11 @@ public class WikiConnector extends org.a
         // We need the caller to abandon any connections left around, so rethrow in a way that forces them to process the event properly.
         throw e;
       }
+      finally
+      {
+        // Make SURE buffer is dead, otherwise child thread may well hang waiting on it
+        pageBuffer.abandon();
+      }
     }
     catch (InterruptedException e)
     {