You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@onami.apache.org by ra...@apache.org on 2013/03/02 16:15:43 UTC

svn commit: r1451894 - /incubator/onami/trunk/scopes/src/test/java/org/apache/onami/scopes/TestConcurrentLazySingleton.java

Author: randgalt
Date: Sat Mar  2 15:15:43 2013
New Revision: 1451894

URL: http://svn.apache.org/r1451894
Log:
ONAMI-91 - make sure executor shuts down

Modified:
    incubator/onami/trunk/scopes/src/test/java/org/apache/onami/scopes/TestConcurrentLazySingleton.java

Modified: incubator/onami/trunk/scopes/src/test/java/org/apache/onami/scopes/TestConcurrentLazySingleton.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/scopes/src/test/java/org/apache/onami/scopes/TestConcurrentLazySingleton.java?rev=1451894&r1=1451893&r2=1451894&view=diff
==============================================================================
--- incubator/onami/trunk/scopes/src/test/java/org/apache/onami/scopes/TestConcurrentLazySingleton.java (original)
+++ incubator/onami/trunk/scopes/src/test/java/org/apache/onami/scopes/TestConcurrentLazySingleton.java Sat Mar  2 15:15:43 2013
@@ -32,6 +32,7 @@ import org.junit.runner.RunWith;
 
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @RunWith(OnamiRunner.class)
@@ -65,17 +66,25 @@ public class TestConcurrentLazySingleton
             throws InterruptedException
         {
             final CountDownLatch latch = new CountDownLatch( 1 );
-            Executors.newSingleThreadExecutor().submit( new Callable<Object>()
+            ExecutorService executorService = Executors.newSingleThreadExecutor();
+            try
             {
-                public Object call()
-                    throws Exception
+                executorService.submit( new Callable<Object>()
                 {
-                    injector.getInstance( AnnotatedConcurrentLazySingletonObject.class );
-                    latch.countDown();
-                    return null;
-                }
-            } );
-            latch.await();
+                    public Object call()
+                        throws Exception
+                    {
+                        injector.getInstance( AnnotatedConcurrentLazySingletonObject.class );
+                        latch.countDown();
+                        return null;
+                    }
+                } );
+                latch.await();
+            }
+            finally
+            {
+                executorService.shutdownNow();
+            }
         }
     }