[jboss-cvs] JBossAS SVN: r109076 - in projects/ejb3/tags/jboss-ejb3-core-1.3.6/src: test/java/org/jboss/ejb3/core/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 2 14:26:36 EDT 2010


Author: jbertram at redhat.com
Date: 2010-11-02 14:26:36 -0400 (Tue, 02 Nov 2010)
New Revision: 109076

Removed:
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/
Modified:
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/main/java/org/jboss/ejb3/pool/StrictMaxPool.java
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
Log:
JBPAPP-5356 reverting accidental changes

Modified: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/main/java/org/jboss/ejb3/pool/StrictMaxPool.java
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/main/java/org/jboss/ejb3/pool/StrictMaxPool.java	2010-11-02 17:56:58 UTC (rev 109075)
+++ projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/main/java/org/jboss/ejb3/pool/StrictMaxPool.java	2010-11-02 18:26:36 UTC (rev 109076)
@@ -21,15 +21,16 @@
  */
 package org.jboss.ejb3.pool;
 
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-import org.jboss.logging.Logger;
-
-import javax.ejb.EJBException;
 import java.util.LinkedList;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 
+import javax.ejb.EJBException;
+
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Container;
+import org.jboss.logging.Logger;
+
 /**
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
  * @version $Revision$
@@ -65,43 +66,13 @@
 
    Logger log = Logger.getLogger(StrictMaxPool.class);
 
-   /**
-    * Acquire a permit and check the pool.
-    *
-    * @return a BeanContext from the pool or null if one needs to be created
-    */
-   private BeanContext acquire()
-   {
-      boolean trace = log.isTraceEnabled();
-      if (trace)
-         log.trace("Get instance " + this + "#" + pool.size() + "#" + container.getBeanClass());
 
-      // Block until an instance is available
-      try
-      {
-         boolean acquired = strictMaxSize.tryAcquire(strictTimeout, TimeUnit.MILLISECONDS);
-         if (trace)
-            log.trace("Acquired(" + acquired + ") strictMaxSize semaphore, remaining=" + strictMaxSize.availablePermits());
-         if (acquired == false)
-            throw new EJBException("Failed to acquire the pool semaphore, strictTimeout=" + strictTimeout);
-      }
-      catch (InterruptedException e)
-      {
-         throw new EJBException("Pool strictMaxSize semaphore was interrupted");
-      }
+   // Static --------------------------------------------------------
 
-      synchronized (pool)
-      {
-         if (!pool.isEmpty())
-         {
-            BeanContext bean = (BeanContext) pool.removeFirst();
-            ++inUse;
-            return bean;
-         }
-      }
-      return null;
-   }
+   // Constructors --------------------------------------------------
 
+   // Public --------------------------------------------------------
+
    /**
     * super.initialize() must have been called in advance
     */
@@ -142,48 +113,73 @@
     */
    public BeanContext get()
    {
-      BeanContext bean = acquire();
-      if(bean != null)
-         return bean;
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+         log.trace("Get instance " + this + "#" + pool.size() + "#" + container.getBeanClass());
 
+      // Block until an instance is available
       try
       {
-         // Pool is empty, create an instance
-         ++inUse;
-         bean = create();
+         boolean acquired = strictMaxSize.tryAcquire(strictTimeout, TimeUnit.MILLISECONDS);
+         if (trace)
+            log.trace("Acquired(" + acquired + ") strictMaxSize semaphore, remaining=" + strictMaxSize.availablePermits());
+         if (acquired == false)
+            throw new EJBException("Failed to acquire the pool semaphore, strictTimeout=" + strictTimeout);
       }
-      finally
+      catch (InterruptedException e)
       {
-         if(bean == null)
+         throw new EJBException("Pool strictMaxSize semaphore was interrupted");
+      }
+
+      synchronized (pool)
+      {
+         if (!pool.isEmpty())
          {
-            --inUse;
-            strictMaxSize.release();
+            BeanContext bean = (BeanContext) pool.removeFirst();
+            ++inUse;
+            return bean;
          }
       }
-      return bean;
+
+      // Pool is empty, create an instance
+      ++inUse;
+      return create();
+
    }
 
    public BeanContext get(Class[] initTypes, Object[] initValues)
    {
-      BeanContext bean = acquire();
-      if(bean != null)
-         return bean;
-      
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+         log.trace("Get instance " + this + "#" + pool.size() + "#" + container.getBeanClass());
+
+      // Block until an instance is available
       try
       {
-         // Pool is empty, create an instance
-         ++inUse;
-         bean = create(initTypes, initValues);
+         boolean acquired = strictMaxSize.tryAcquire(strictTimeout, TimeUnit.MILLISECONDS);
+         if (trace)
+            log.trace("Acquired(" + acquired + ") strictMaxSize semaphore, remaining=" + strictMaxSize.availablePermits());
+         if (acquired == false)
+            throw new EJBException("Failed to acquire the pool semaphore, strictTimeout=" + strictTimeout);
       }
-      finally
+      catch (InterruptedException e)
       {
-         if(bean == null)
+         throw new EJBException("Pool strictMaxSize semaphore was interrupted");
+      }
+
+      synchronized (pool)
+      {
+         if (!pool.isEmpty())
          {
-            --inUse;
-            strictMaxSize.release();
+            BeanContext bean = (BeanContext) pool.removeFirst();
+            ++inUse;
+            return bean;
          }
       }
-      return bean;
+
+      // Pool is empty, create an instance
+      ++inUse;
+      return create(initTypes, initValues);
    }
 
    /**

Modified: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java	2010-11-02 17:56:58 UTC (rev 109075)
+++ projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java	2010-11-02 18:26:36 UTC (rev 109076)
@@ -73,8 +73,6 @@
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
-import static org.junit.Assert.assertEquals;
-
 /**
  * Create an environment with some basic facilities on which EJB 3 containers
  * depend.
@@ -133,20 +131,6 @@
 
    }
 
-   protected static void assertCause(Throwable expected, Throwable actual)
-   {
-      Throwable cause = actual.getCause();
-      if(cause != null)
-         assertCause(expected, cause);
-      else
-         assertThrowable(expected, actual);
-   }
-
-   protected static void assertThrowable(Throwable expected, Throwable actual)
-   {
-      assertEquals(expected.toString(), actual.toString());
-   }
-
    @BeforeClass
    public static void beforeClass() throws Exception
    {



More information about the jboss-cvs-commits mailing list