private void releaseInstance(final EjbComponentInstance instance) {
   if (pool != null) {
     pool.release(instance);
   } else {
     instance.destroy();
   }
 }
 @Override
 public void callTimeout(final TimerImpl timer, final Method timeoutMethod) throws Exception {
   final EjbComponentInstance instance = acquireInstance();
   boolean discarded = false;
   try {
     instance.invokeTimeoutMethod(timeoutMethod, timer);
   } catch (Exception ex) {
     // Detect app exception
     if (ejbComponent.getApplicationException(ex.getClass(), timeoutMethod) != null) {
       // it's an application exception, just throw it back.
       throw ex;
     }
     if (ex instanceof ConcurrentAccessTimeoutException
         || ex instanceof ConcurrentAccessException) {
       throw ex;
     }
     if (ex instanceof RuntimeException || ex instanceof RemoteException) {
       discarded = true;
       if (pool != null) {
         pool.discard(instance);
       }
     }
     throw ex;
   } catch (final Error e) {
     discarded = true;
     if (pool != null) {
       pool.discard(instance);
     }
     throw e;
   } catch (final Throwable t) {
     discarded = true;
     if (pool != null) {
       pool.discard(instance);
     }
     throw new RuntimeException(t);
   } finally {
     if (!discarded) {
       releaseInstance(instance);
     }
   }
 }