Index: src/test/org/jboss/ejb3/test/stateless/unit/MetricsUnitTestCase.java
===================================================================
--- src/test/org/jboss/ejb3/test/stateless/unit/MetricsUnitTestCase.java	(revision 96627)
+++ src/test/org/jboss/ejb3/test/stateless/unit/MetricsUnitTestCase.java	(working copy)
@@ -47,6 +47,11 @@
    
    public void testDefaultJmxMetrics() throws Exception
    {
+	   // The default pool used by a SLSB is the ThreadLocalPool
+	   // For a detailed explanation about what each metric value
+	   // means when a ThreadLocalPool is used, check the comments
+	   // from carlo in this JIRA https://jira.jboss.org/jira/browse/EJBTHREE-1703
+	  
       MBeanServerConnection server = getServer();
       ObjectName testerName = new ObjectName("jboss.j2ee:jar=stateless-test.jar,name=DefaultPoolStatelessBean,service=EJB3");
       
@@ -66,10 +71,10 @@
       assertEquals(1, size);
       
       size = (Integer)server.getAttribute(testerName, "AvailableCount");
-      assertEquals(30, size);
+      assertEquals(1, size);
       
       size = (Integer)server.getAttribute(testerName, "MaxSize");
-      assertEquals(30, size);
+      assertEquals(1, size);
       
       size = (Integer)server.getAttribute(testerName, "CreateCount");
       assertEquals(1, size);
@@ -104,15 +109,17 @@
       size = (Integer)server.getAttribute(testerName, "MaxSize");
       assertEquals(3, size);
       
-      size = (Integer)server.getAttribute(testerName, "CreateCount");
-      assertEquals(1, size);
+      int createCount = (Integer)server.getAttribute(testerName, "CreateCount");
+      assertEquals(1, createCount);
       
       runConcurrentTests(20, 1);
       
       int currentSize = (Integer)server.getAttribute(testerName, "CurrentSize");
-      assertEquals(1, size);
+
       
       checkMetrics(server, testerName, currentSize, 3, 3, currentSize, 0);
+      
+      createCount = (Integer)server.getAttribute(testerName, "CreateCount");
      
       for (int i = 1 ; i <= 10 ; ++i)
       {
@@ -129,13 +136,44 @@
          }
       }
       
+      //  New instances should have been created in the loop above,
+      // since 10 bean instances were discarded because of exception.
+      int createCountAfterExceptionOnBeanInstances = (Integer)server.getAttribute(testerName, "CreateCount");
+      assertTrue("New instances not created", createCountAfterExceptionOnBeanInstances > createCount);
+
+
+      // 10 method calls led to exceptions so 10 bean instances would be removed
+      int removedCount = (Integer)server.getAttribute(testerName, "RemoveCount");
+      assertEquals("Removed count does not match", 10, removedCount);
+
+      // current size (created - removed) should now be zero
+      // since all the created ones have been removed after exception
+      currentSize = (Integer)server.getAttribute(testerName, "CurrentSize");
+      assertEquals("Current size is incorrect", 0, currentSize);
+
+      // none of the instances are in use, so available count should be
+      // max (=3)
+      int availableCount = (Integer) server.getAttribute(testerName, "AvailableCount");
+      assertEquals("Available count does not match", 3, availableCount);
+
+
+      // one more round of concurrent invocations
       runConcurrentTests(20, 1);
+
+      // again there should be no "inUse" instances and hence available count
+      // should be equal to max (=3)
+      availableCount = (Integer) server.getAttribute(testerName, "AvailableCount");
+      assertEquals("Available count not matching", 3, availableCount);
+
+      // some new instances should have been created in runconcurrent tests,
+      // since all the bean instances were earlier removed because of exception.
+      // We won't know the exact count because of the thread concurrency involved
+      // but the create count should definitely be greater than the earlier
+      // create count
+      createCount = (Integer)server.getAttribute(testerName, "CreateCount");
+      assertTrue("Create count does not match after concurrent test",createCount > createCountAfterExceptionOnBeanInstances);
+
       
-      currentSize = (Integer)server.getAttribute(testerName, "CurrentSize");
-      assertEquals(1, size);
-      
-      checkMetrics(server, testerName, currentSize, 3, 3, currentSize + 10, 10);
-      
       Runnable r = new Runnable()
       {
          public void run()
@@ -159,7 +197,7 @@
       int maxSize = (Integer)server.getAttribute(testerName, "MaxSize");
       System.out.println("MaxSize=" + maxSize);
       
-      int availableCount = (Integer)server.getAttribute(testerName, "AvailableCount");
+      availableCount = (Integer)server.getAttribute(testerName, "AvailableCount");
       System.out.println("AvailableCount=" + availableCount);
      
       assertEquals(maxSize - 1, availableCount);
Index: src/main/org/jboss/ejb3/StrictMaxPool.java
===================================================================
--- src/main/org/jboss/ejb3/StrictMaxPool.java	(revision 96627)
+++ src/main/org/jboss/ejb3/StrictMaxPool.java	(working copy)
@@ -240,8 +240,8 @@
       strictMaxSize.release();
       --inUse;
 
-      // Throw away, unsetContext()
-      super.discard(ctx);
+      // Let the super do any other remove stuff
+      super.doRemove(ctx);
    }
 
    // Package protected ---------------------------------------------
@@ -288,6 +288,7 @@
       strictMaxSize.release();
       --inUse;
 
-      super.remove(ctx);
+      // let the super do the other remove stuff
+      super.doRemove(ctx);
    }
 }
Index: src/main/org/jboss/ejb3/AbstractPool.java
===================================================================
--- src/main/org/jboss/ejb3/AbstractPool.java	(revision 96627)
+++ src/main/org/jboss/ejb3/AbstractPool.java	(working copy)
@@ -24,6 +24,7 @@
 import org.jboss.injection.Injector;
 import org.jboss.annotation.ejb.cache.tree.CacheConfig;
 import org.jboss.aop.Advisor;
+import org.jboss.ejb3.BeanContext;
 import org.jboss.ejb3.stateful.StatefulBeanContext;
 import org.jboss.logging.Logger;
 import org.jboss.util.id.GUID;
@@ -215,20 +216,12 @@
    
    public void remove(BeanContext ctx)
    {
-      try
-      {
-         container.invokePreDestroy(ctx);
-      }
-      finally
-      {
-         ctx.remove();
-         ++removeCount;
-      }
+      this.doRemove(ctx);
    }
 
    public void discard(BeanContext ctx)
    {
-      remove(ctx);
+      this.doRemove(ctx);
    }
 
    public void setInjectors(Injector[] injectors)
@@ -245,4 +238,23 @@
    {
       return removeCount;
    }
+   
+   /**
+    * Remove the bean context and invoke any callbacks
+    * and track the remove count
+    *
+    * @param ctx
+    */
+   protected void doRemove(BeanContext ctx)
+   {
+      try
+      {
+         container.invokePreDestroy(ctx);
+      }
+      finally
+      {
+         ctx.remove();
+         ++removeCount;
+      }
+   }
 }
