public boolean lock(Object lockName, Locker locker, int mode)
                    throws InterruptedException,
                    LockException
    {
        Lock theLock = null;

        synchronized (lockTable) {

            Object o = lockTable.put(lockName, locker);
            if (o == null || o == locker) {

                //--------------------------------------------------------
                // Fastpath: no conflicts, just leave locker  as
                // placeholder in case another attempt is made to acquire
                // this lock before it is released.
                //--------------------------------------------------------

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "lock acquired",
                             new Object[] { lockName, locker, modeStrs[mode] });
                }

                return (o == null);

            } else {

                //--------------------------------------------------------
                // Conflict, upgrade LockProxy to full lock if necessary.
                //--------------------------------------------------------

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Conflict : Lock upgrading from proxy",
                             new Object[] { lockName, locker,
                                           modeStrs[mode] });
                }

                LockProxy l = (LockProxy) o;
                if (l.isLock())
                {
                    theLock = (Lock) l;

                    // If the locker is already a holder of the lock, then
                    // lock succeeds, return false (already held).     PQ53065
                    if (theLock.isHolder(locker))
                    {
                        // Put the lock back into the table or the waiters will
                        // be waiting forever.                          d114715
                        lockTable.put(lockName, theLock);

                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "lock acquired (already held)",
                                     new Object[] { lockName, locker, modeStrs[mode] });
                        }
                        return false;
                    }
                }
                else
                {
                    theLock = new Lock(lockName, (Locker) o, this);
                }
                lockTable.put(lockName, theLock);
                theLock.acquire(locker, mode, false);
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Conflict : Lock upgraded from proxy",
                             new Object[] { lockName, locker,
                                           modeStrs[mode] });
                }
            }
        }

        //----------------------------------------------------------------
        // Acquire the lock outside the synchronization on the lockTable
        // so that other lock requests may proceed since acquisition may
        // block the current thread until the lock is acquired.
        //----------------------------------------------------------------

        theLock.acquire(locker, mode, true);

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "lock acquired",
                     new Object[] { lockName, locker, modeStrs[mode] });
        }

        return true;
    }
public boolean lock ( Object lockName , Locker locker , int mode ) throws InterruptedException , LockException { Lock theLock = null ; synchronized ( lockTable ) { Object o = lockTable . put ( lockName , locker ) ; if ( o == null || o == locker ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "lock acquired" , new Object [ ] { lockName , locker , modeStrs [ mode ] } ) ; } return ( o == null ) ; } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Conflict : Lock upgrading from proxy" , new Object [ ] { lockName , locker , modeStrs [ mode ] } ) ; } LockProxy l = ( LockProxy ) o ; if ( l . isLock ( ) ) { theLock = ( Lock ) l ; if ( theLock . isHolder ( locker ) ) { lockTable . put ( lockName , theLock ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "lock acquired (already held)" , new Object [ ] { lockName , locker , modeStrs [ mode ] } ) ; } return false ; } } else { theLock = new Lock ( lockName , ( Locker ) o , this ) ; } lockTable . put ( lockName , theLock ) ; theLock . acquire ( locker , mode , false ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Conflict : Lock upgraded from proxy" , new Object [ ] { lockName , locker , modeStrs [ mode ] } ) ; } } } theLock . acquire ( locker , mode , true ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "lock acquired" , new Object [ ] { lockName , locker , modeStrs [ mode ] } ) ; } return true ; }
PQ53065