Return the mcWrapper to the free pool.

@pre mcWrapper != null
776574
protected void returnToFreePool(MCWrapper mcWrapper) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(this, tc, "returnToFreePool", gConfigProps.cfName);
        }
        if (mcWrapper.shouldBeDestroyed() || mcWrapper.hasFatalErrorNotificationOccurred(fatalErrorNotificationTime)
            || ((pm.agedTimeout != -1)
                && (mcWrapper.hasAgedTimedOut(pm.agedTimeoutMillis)))) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                if (mcWrapper.shouldBeDestroyed()) {
                    Tr.debug(this, tc, "Connection destroy flag is set, removing connection " + mcWrapper);
                }
                if (mcWrapper.hasFatalErrorNotificationOccurred(fatalErrorNotificationTime)) {
                    Tr.debug(this, tc, "Fatal error occurred, removing connection " + mcWrapper);
                }
                if (((pm.agedTimeout != -1) && (mcWrapper.hasAgedTimedOut(pm.agedTimeoutMillis)))) {
                    Tr.debug(this, tc, "Aged timeout exceeded, removing connection " + mcWrapper);
                }
                if (mcWrapper.isDestroyState()) {
                    Tr.debug(this, tc, "Mbean method purgePoolContents with option immediate was used." +
                                       "  Connection cleanup and destroy is being processed.");
                }
            }
            if (mcWrapper.isDestroyState()) {
                final FreePool tempFP = this;
                final MCWrapper tempMCWrapper = mcWrapper;
                ThreadSupportedCleanupAndDestroy tscd = new ThreadSupportedCleanupAndDestroy(pm.tscdList, tempFP, tempMCWrapper);
                pm.tscdList.add(tscd);
                pm.connectorSvc.execSvcRef.getServiceWithException().submit(tscd);
            } else {
                cleanupAndDestroyMCWrapper(mcWrapper); // cleanup, remove, then release mcWrapper
                // Do not return this mcWrapper back to the free pool.
                removeMCWrapperFromList(mcWrapper, _mcWrapperDoesNotExistInFreePool, _synchronizeInMethod, _notifyWaiter, _decrementTotalCounter);
            }
        } else {
            returnToFreePoolDelegated(mcWrapper); // Added to Help PMI Stuff.Unable to inject code in if/else conditional situations.
        } // end else -- the mcWrapper is not stale

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(this, tc, "returnToFreePool");
        }
    }
874912
public RowIdWrapper getCurrentRowIdWrapper() {
		UIContext uic = UIContextHolder.getCurrent();
		if (uic instanceof SubUIContext) {
			int index = ((SubUIContext) uic).getRowIndex();
			RowIdWrapper wrapper = table.getRepeater().getBeanList().get(index);
			return wrapper;
		}
		return null;
	}
755184
protected synchronized WriterPoolMember makeNewWriterIfAppropriate() {
	    long now = System.currentTimeMillis();
	    lastWriterNeededTime = now; 
        if(currentActive < maxActive) {
            currentActive++;
            lastWriterRolloverTime = now; 
            return makeWriter(); 
        }
        return null; 
    }
56551
protected NoTransactionWrapper getNoTransactionWrapper() {

        final boolean isTracingEnabled = TraceComponent.isAnyTracingEnabled();

        if (isTracingEnabled && tc.isEntryEnabled()) {
            Tr.entry(this, tc, "getNoTransactionWrapper");
        }

        if (noTranWrapper == null) {
            noTranWrapper = new NoTransactionWrapper();
        }

        if (state == STATE_ACTIVE_INUSE) {
            state = STATE_TRAN_WRAPPER_INUSE;
            tranWrapperInUse = NOTXWRAPPER;
        } else { // state not STATE_ACTIVE_INUSE
            if (state != STATE_TRAN_WRAPPER_INUSE) {
                IllegalStateException e = new IllegalStateException("getNoTransactionWrapper: illegal state exception. State = " + getStateString() + " MCW = "
                                                                    + mcWrapperObject_hexString);
                Object[] parms = new Object[] { "getNoTransactionWrapper", e };
                Tr.error(tc, "ILLEGAL_STATE_EXCEPTION_J2CA0079", parms);
                throw e;
            } else { // state is STATE_TRAN_WRAPPER_INUSE
                if (tranWrapperInUse == NONE) {
                    tranWrapperInUse = NOTXWRAPPER;
                } else { //tranWrapperInUse is NOT NONE
                    if (tranWrapperInUse != NOTXWRAPPER) {
                        // Need RAS and Trace here.
                        IllegalStateException e = new IllegalStateException("getNoTransactionWrapper: illegal transaction state exception. State = "
                                                                            + getTranWrapperString());
                        Object[] parms = new Object[] { "getNoTransactionWrapper", e };
                        Tr.error(tc, "ILLEGAL_STATE_EXCEPTION_J2CA0079", parms);
                        throw e;
                    }
                }
            }
        }

        if (isTracingEnabled && tc.isEntryEnabled()) {
            Tr.exit(this, tc, "getNoTransactionWrapper");
        }

        return noTranWrapper;

    }
165725
public Object getMCWFromMctoMCWMap(Object mc) {
        Object mcw = null;
        mcToMCWMapRead.lock();
        try {
            mcw = mcToMCWMap.get(mc);
        } finally {
            mcToMCWMapRead.unlock();
        }
        return mcw;
    }
1266445
@Override
    public <T> T unwrap(Class<T> clazz) {
        return Session.class.isAssignableFrom(clazz) ? clazz.cast(session) : null;
    }
86678
public T acquire() {
    if (closed) {
      throw new IllegalStateException("pool closed");
    }

    T reference = pool.poll();
    if (reference == null) {
      reference = factory.createReference(this);
    }
    reference.acquire();
    return reference;
  }
787224
@SuppressWarnings("unchecked")
  private E borrowInternal() {

    if (this.size > 0) {
      E element = (E) this.pool[this.size];
      this.pool[this.size--] = null;
      return element;
    } else {
      return create();
    }
  }
353785
@Nullable
    private ThreadPoolExecutor unwrapThreadPoolExecutor(ExecutorService executor, Class<?> wrapper) {
        try {
            Field e = wrapper.getDeclaredField("e");
            e.setAccessible(true);
            return (ThreadPoolExecutor) e.get(executorService);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            // Do nothing. We simply can't get to the underlying ThreadPoolExecutor.
        }
        return null;
    }
1088413
private MyWrapper asMyWrapper(StringWrapper w)
    {
	if (w instanceof MyWrapper) return (MyWrapper)w;
	else return new MyWrapper(w.unwrap());
    }
129689
protected WSJdbcResultSet createWrapper(ResultSet rsetImpl) {
        // If the childWrapper is null, and the childWrappers is null or 
        // empty, set the result set to childWrapper;
        // Otherwise, add the result set to childWrappers
        WSJdbcResultSet rsetWrapper;
        if (childWrapper == null && (childWrappers == null || childWrappers.isEmpty())) {
            childWrapper = rsetWrapper = mcf.jdbcRuntime.newResultSet(rsetImpl, this);
            if (TraceComponent.isAnyTracingEnabled() &&  tc.isDebugEnabled())
                Tr.debug(tc, "Set the result set to child wrapper"); 
        } else {
            if (childWrappers == null) 
                childWrappers = new ArrayList<Wrapper>(5); 
            rsetWrapper = mcf.jdbcRuntime.newResultSet(rsetImpl, this);
            childWrappers.add(rsetWrapper);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Add the result set to child wrappers list."); 
        }

        return rsetWrapper;
    }
1374181
public Object get()
    {
        synchronized(this)
        {
            if (freePool.isEmpty() || usedPool.size() >= capacity)
            {
                try
                {
                    wait(1000);
                } 
                catch (InterruptedException e)
                {
                }

                // The timeout value was reached
                if (freePool.isEmpty())
                    add(new SimpleDateFormat());
            }

            Object o = freePool.get(0);
            freePool.remove(o);
            usedPool.add(o);
            return o;
        }
    }
1369550
public synchronized Object getInstanceIfFree()
  {

    // Check if the pool is empty.
    if (!freeStack.isEmpty())
    {

      // Remove object from end of free pool.
      Object result = freeStack.remove(freeStack.size() - 1);
      return result;
    }

    return null;
  }
915987
public static <T> PoolableWrapper<T> of(T srcObject, long liveTime, long maxIdleTime) {
        return new PoolableWrapper<T>(srcObject, liveTime, maxIdleTime);
    }
172587
public @CheckForNull R get() {
        Holder<R> h = holder; // capture
        return h!=null ? h.get() : null;
    }
1269346
@SuppressWarnings("unchecked")
    public T get() {
        if (HystrixRequestContext.getContextForCurrentThread() == null) {
            throw new IllegalStateException(HystrixRequestContext.class.getSimpleName() + ".initializeContext() must be called at the beginning of each request before RequestVariable functionality can be used.");
        }
        ConcurrentHashMap<HystrixRequestVariableDefault<?>, LazyInitializer<?>> variableMap = HystrixRequestContext.getContextForCurrentThread().state;

        // short-circuit the synchronized path below if we already have the value in the ConcurrentHashMap
        LazyInitializer<?> v = variableMap.get(this);
        if (v != null) {
            return (T) v.get();
        }

        /*
         * Optimistically create a LazyInitializer to put into the ConcurrentHashMap.
         * 
         * The LazyInitializer will not invoke initialValue() unless the get() method is invoked
         * so we can optimistically instantiate LazyInitializer and then discard for garbage collection
         * if the putIfAbsent fails.
         * 
         * Whichever instance of LazyInitializer succeeds will then have get() invoked which will call
         * the initialValue() method once-and-only-once.
         */
        LazyInitializer<T> l = new LazyInitializer<T>(this);
        LazyInitializer<?> existing = variableMap.putIfAbsent(this, l);
        if (existing == null) {
            /*
             * We won the thread-race so can use 'l' that we just created.
             */
            return l.get();
        } else {
            /*
             * We lost the thread-race so let 'l' be garbage collected and instead return 'existing'
             */
            return (T) existing.get();
        }
    }
1089860
@Override
    public T get() {
        final Supplier<T> delegate = this.delegate;
        return delegate != null ? delegate.get() : null;
    }