static void releaseInstance(final StatefulSessionComponentInstance instance, boolean toDiscard) {
        try {
            if (!instance.isDiscarded() && !toDiscard) {
                // mark the SFSB instance as no longer in use
                instance.getComponent().getCache().release(instance);
            }
        } finally {
            instance.setSynchronizationRegistered(false);
            // release the lock on the SFSB instance
            releaseLock(instance);
        }
    }
static void releaseInstance ( final StatefulSessionComponentInstance instance , boolean toDiscard ) { try { if ( ! instance . isDiscarded ( ) && ! toDiscard ) { instance . getComponent ( ) . getCache ( ) . release ( instance ) ; } } finally { instance . setSynchronizationRegistered ( false ) ; releaseLock ( instance ) ; } }
Releases the passed {@link StatefulSessionComponentInstance} i.e. marks it as no longer in use. After releasing the
instance, this method releases the lock, held by this thread, on the stateful component instance.

@param instance The stateful component instance
@param toDiscard indicates if bean should be discarded due to exception