Scarab commit: svn commit: r10569 - trunk/src/java/org/tigris/scarab/util/word/IssueSearchFactory.java

[email protected]
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: hair
Date: 2008-05-08 01:02:04-0700
New Revision: 10569

Modified:
   trunk/src/java/org/tigris/scarab/util/word/IssueSearchFactory.java

Log:
fix leaking count of open IssueSearch instances.
 - http://scarab.tigris.org/servlets/ReadMsg?list=dev&msgNo=14364

Modified: trunk/src/java/org/tigris/scarab/util/word/IssueSearchFactory.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/util/word/IssueSearchFactory.java?view=diff&rev=10569&p1=trunk/src/java/org/tigris/scarab/util/word/IssueSearchFactory.java&p2=trunk/src/java/org/tigris/scarab/util/word/IssueSearchFactory.java&r1=10568&r2=10569
==============================================================================
--- trunk/src/java/org/tigris/scarab/util/word/IssueSearchFactory.java	(original)
+++ trunk/src/java/org/tigris/scarab/util/word/IssueSearchFactory.java	2008-05-08 01:02:04-0700
@@ -143,32 +143,37 @@
     }
 
     synchronized void register()
-        throws ScarabException, InterruptedException
+        throws MaxConcurrentSearchException, InterruptedException
     {
-        long starttime = System.currentTimeMillis();
-        while (numActive > maxInstances) 
+        try
         {
-            try 
+            long starttime = System.currentTimeMillis();
+            while (numActive > maxInstances) 
             {
-                wait(1000);
-            }
-            catch(InterruptedException e) 
-            {
-                notify();
-                throw e;
-            }
-            if(System.currentTimeMillis() - starttime > maxWait) 
-            {
-                // the caller is expected in a final block to decrement the count 
-                //  regardless if a valid IssueSearch was returned or not or whatever exception was thrown.
-                numActive++;
-                throw new MaxConcurrentSearchException(
-                    L10NKeySet.ExceptionMaxConcurrentSearch,
-                    ""+this.getMaxWait()
-                    );
-            }
-        }    
-        numActive++;
+                try 
+                {
+                    wait(1000);
+                }
+                catch(InterruptedException e) 
+                {
+                    notify();
+                    throw e;
+                }
+                if(System.currentTimeMillis() - starttime > maxWait) 
+                {
+                    throw new MaxConcurrentSearchException(
+                        L10NKeySet.ExceptionMaxConcurrentSearch,
+                        ""+this.getMaxWait()
+                        );
+                }
+            }    
+        }
+        finally
+        {
+            // the caller is expected in a final block to decrement the count 
+            //  regardless if a valid IssueSearch was returned or not or whatever exception was thrown.
+            numActive++;
+        }
     }
 
     synchronized public void notifyDone()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.