/* (non-Javadoc)
@see com.ibm.wsspi.sib.core.LockedMessageEnumeration#unlockCurrent()
541491
public void unlockCurrent() 
  throws SISessionUnavailableException, SISessionDroppedException,
         SIResourceException, SIConnectionLostException, 
         SIIncorrectCallException,
         SIErrorException, SIMPMessageNotLockedException
  {
    if (TraceComponent.isAnyTracingEnabled() && CoreSPILockedMessageEnumeration.tc.isEntryEnabled())
      SibTr.entry(CoreSPILockedMessageEnumeration.tc, "unlockCurrent", 
        new Object[] { new Integer(hashCode()), this});
    
    unlockCurrent(false);

    if (TraceComponent.isAnyTracingEnabled() && CoreSPILockedMessageEnumeration.tc.isEntryEnabled())
      SibTr.exit(CoreSPILockedMessageEnumeration.tc, "unlockCurrent", this);
  }
1266787
public final void unlockFromUpgrade(L locker) {
        int upgradeCount = mUpgradeCount - 1;
        if (upgradeCount < 0) {
            throw new IllegalMonitorStateException("Too many upgrade locks released");
        }
        if (upgradeCount == 0 && mWriteCount > 0) {
            // Don't release last upgrade lock and switch write lock to
            // automatic upgrade mode.
            clearUpgradeLock(mState);
            return;
        }
        mUpgradeCount = upgradeCount;
        if (upgradeCount > 0) {
            return;
        }

        mOwner = null;

        // keep looping on CAS failure if reader mucked with state
        while (!clearUpgradeLock(mState)) {}

        Node h = mUHead;
        if (h != null && h.mWaitStatus != 0) {
            unparkUpgradeSuccessor(h);
        }
    }
841879
void tryUnlockCurrent() {

        if ((m_lockAction != null) && m_lockAction.getChange().equals(CmsLockActionRecord.LockChange.locked)) {
            try {
                A_CmsUI.getCmsObject().unlockResource(m_currentResource);
            } catch (CmsException e) {
                e.printStackTrace();
            }
        }
    }
401978
@Override
    public boolean removeFirstOccurrence(DelayedEntry incoming) {
        Data incomingKey = (Data) incoming.getKey();
        Object incomingValue = incoming.getValue();

        DelayedEntry current = map.get(incomingKey);
        if (current == null) {
            return false;
        }

        Object currentValue = current.getValue();
        if (incomingValue == null && currentValue == null
                || incomingValue != null && currentValue != null && incomingValue.equals(currentValue)) {
            map.remove(incomingKey);
            return true;
        }

        return false;
    }
768673
protected int getNumberOfLockedMessages()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getNumberOfLockedMessages");

    int count = 0;

    synchronized(this)
    {
      LMEMessage message;

      message = firstMsg;
      while(message != null)
      {
        count++;
        message = message.next;
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getNumberOfLockedMessages", new Integer(count));
    return count;
  }
1102207
public Object current() {
        Entry entry = flushedEntry;
        if (entry == null) {
            return null;
        }

        return entry.msg;
    }
23766
public void unlockSet(SIMessageHandle[] msgHandles)
      throws SIIncorrectCallException, SIMessageNotLockedException,
             SIConnectionDroppedException, SIConnectionLostException
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "unlockSet", msgHandles);

      if (sessionId == 0)
      {
         // If the session Id = 0, then no one called setSessionId(). As such we are unable to flow
         // to the server as we do not know which session to instruct the server to use.
         SIErrorException e = new SIErrorException(
            nls.getFormattedMessage("SESSION_ID_HAS_NOT_BEEN_SET_SICO1043", null, null)
         );

         FFDCFilter.processException(e, CLASS_NAME + ".unlockSet",
                                     CommsConstants.CONVERSATIONHELPERIMPL_12, this);

         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, e.getMessage(), e);

         throw e;
      }

      if (msgHandles == null)
      {
         // Null msg Id's are no good
         SIErrorException e = new SIErrorException(
            nls.getFormattedMessage("NULL_MESSAGE_IDS_PASSED_IN_SICO1044", null, null)
         );

         FFDCFilter.processException(e, CLASS_NAME + ".unlockSet",
                                     CommsConstants.CONVERSATIONHELPERIMPL_13, this);

         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, e.getMessage(), e);

         throw e;
      }

      CommsByteBuffer request = getCommsByteBuffer();
      // Connection object id
      request.putShort(connectionObjectId);
      // Consumer session id
      request.putShort(sessionId);
      // Message handles
      request.putSIMessageHandles(msgHandles);
      
      //Flowing incrementLockCount field is only valid for faps 7, 8 and greater than 9.
      //In this case we should always flow a 1 (true) so we don't change existing behaviour.
      final int fapLevel = getConversation().getHandshakeProperties().getFapLevel();
      if(!(fapLevel < JFapChannelConstants.FAP_VERSION_7 || fapLevel == JFapChannelConstants.FAP_VERSION_9))
      {
         request.put((byte)1);
      }

      // Pass on call to server
      jfapSend(request,
               JFapChannelConstants.SEG_UNLOCK_SET_NOREPLY,
               JFapChannelConstants.PRIORITY_MEDIUM,
               true,
               ThrottlingPolicy.BLOCK_THREAD);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "unlockSet");
   }
1167184
public int getRemainingMessageCount() 
  throws SISessionUnavailableException, SISessionDroppedException,
         SIIncorrectCallException
  {
    if (TraceComponent.isAnyTracingEnabled() && CoreSPILockedMessageEnumeration.tc.isEntryEnabled())
      SibTr.entry(CoreSPILockedMessageEnumeration.tc, "getRemainingMessageCount", this);
          
    checkValidState("getRemainingMessageCount");
          
    _localConsumerPoint.checkNotClosed();
    
    int remaining = 0;
    
    if(!_seenSingleMessage)
    {
      remaining = 1;
    }
    
    if (TraceComponent.isAnyTracingEnabled() && CoreSPILockedMessageEnumeration.tc.isEntryEnabled())
      SibTr.exit(CoreSPILockedMessageEnumeration.tc, "getRemainingMessageCount", 
        new Integer(remaining));    
      
    return remaining;
  }
1153051
public boolean unlock(KeyColumn kc, T requestor) {

        if (!locks.containsKey(kc)) {
            log.info("Local unlock failed: no locks found for {}", kc);
            return false;
        }

        AuditRecord<T> unlocker = new AuditRecord<>(requestor, null);

        AuditRecord<T> holder = locks.get(kc);

        if (!holder.equals(unlocker)) {
            log.error("Local unlock of {} by {} failed: it is held by {}",
                    kc, unlocker, holder);
            return false;
        }

        boolean removed = locks.remove(kc, unlocker);

        if (removed) {
            expiryQueue.remove(kc);
            if (log.isTraceEnabled()) {
                log.trace("Local unlock succeeded: {} namespace={} txn={}",
                        kc, name, requestor);
            }
        } else {
            log.warn("Local unlock warning: lock record for {} disappeared "
                + "during removal; this suggests the lock either expired "
                + "while we were removing it, or that it was erroneously "
                + "unlocked multiple times.", kc);
        }

        // Even if !removed, we're finished unlocking, so return true
        return true;
    }
716005
private final synchronized void unlock()
                    throws ObjectManagerException
    {
        final String methodName = "unlock";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        methodName,
                        new Object[] { transactionLock });

        setState(nextStateForUnlock); // Make the state change. 

        transactionLock = new TransactionLock(null);
        numberOfLocksTaken = 0;
        notify(); // Wake up one waiter.

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       methodName);
    }
103877
final void cmdRemoveExpiring(final long lockId, final PersistentTransaction transaction) throws ProtocolException, TransactionException, SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "cmdRemoveExpiring", new Object[] { "Item Link:   " + this, "Stream Link: " + _owningStreamLink, formatLockId(lockId),
                                                                     "Transaction: " + transaction });

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            SibTr.debug(this, tc, "expiring item " + _tuple.getUniqueId());

        synchronized (this)
        {
            if (ItemLinkState.STATE_LOCKED_FOR_EXPIRY == _itemLinkState)
            {
                if (_lockID != lockId)
                {
                    throw new LockIdMismatch(_lockID, lockId);
                }

                ListStatistics stats = getParentStatistics();
                synchronized (stats)
                {
                    stats.decrementExpiring();
                    stats.incrementRemoving();
                }

                _transactionId = transaction.getPersistentTranId();
                _itemLinkState = ItemLinkState.STATE_REMOVING_EXPIRING;
            }
            else
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                    SibTr.event(this, tc, "Invalid Item state: " + _itemLinkState);
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(this, tc, "cmdRemoveExpiring");
                throw new StateException(_itemLinkState.toString());
            }
        }
        final Task task = new RemoveLockedTask(this);
        transaction.addWork(task);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "cmdRemoveExpiring");
    }
572985
public static void setCurrent(SiteContext current) {
        threadLocal.set(current);

        MDC.put(SITE_NAME_MDC_KEY, current.getSiteName());
    }
1249513
def _unlock(self):
        """"""
        if self.locked:
            try:
                self.device.cu.unlock()
                self.locked = False
            except JnrpUnlockError as jue:
                raise UnlockError(jue.messsage)
109698
public synchronized void unlock()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "unlock", this);

    // If the subscription locks are down to zero then notify the threads waiting
    // for the subscriptionTable lock.
    synchronized (iMutex)
    {
      // If we are exclusively locked, then just return, as long as
      // the thread that is calling is the thread that holds the
      // exclusive lock.
      if (iExclusivelyLocked && iExclusiveLockHolder == Thread.currentThread())
      {
        if (tc.isEntryEnabled())
          SibTr.exit(tc, "unlock");
        return;
      }

      // Decrement the lock count and notify the other threads if no 
      // one holds the lock any more.
      if (--iLockCount == 0)
        notifyAll();
        
      if (iLockCount < 0)
      {      
        if (tc.isEntryEnabled()) 
          SibTr.exit(tc, "unlock", "SIErrorException");
        
        SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
          new Object[] {
            "com.ibm.ws.sib.processor.utils.LockManager",
            "1:196:1.19" });
          
        throw new SIErrorException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0001",
            new Object[] {
              "com.ibm.ws.sib.processor.utils.LockManager",
              "1:203:1.19" },
            null));
      }        
    }

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "unlock");
  }
985313
public K getCurrentKey()
    {
        lock.lock();
        try
        {
            Thread currentThread = Thread.currentThread();
            for (Entry<K,Thread> entry : threadMap.entrySet())
            {
                if (currentThread.equals(entry.getValue()))
                {
                    return entry.getKey();
                }
            }
            return null;
        }
        finally
        {
            lock.unlock();
        }
    }
599029
protected final void unlockMessages(final List messageList, boolean incrementDeliveryCount)
            throws ResourceException {

        final String methodName = "unlockMessages";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName, messageList);
        }

        if (messageList.size() > 0) {

            List listOfSIBusMessages = new ArrayList();
            try {
                  for (int i = 0; i < messageList.size(); i++)
                  {
                    listOfSIBusMessages.add(((DispatchableMessage)messageList.get(i)).getMessage());
                  }
                _session.unlockSet(getMessageHandles(listOfSIBusMessages), incrementDeliveryCount);

            } catch (final SIException exception) {

                FFDCFilter.processException(exception, CLASS_NAME + "."
                        + methodName, "1:1200:1.73", this);
                if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                    SibTr.exception(this, TRACE, exception);
                }
                throw new ResourceAdapterInternalException(NLS
                        .getFormattedMessage(("UNLOCK_EXCEPTION_CWSIV0601"),
                                new Object[] { exception, listOfSIBusMessages }, null),
                        exception);

            } catch (final SIErrorException exception) {

                FFDCFilter.processException(exception, CLASS_NAME + "."
                        + methodName, "1:1212:1.73", this);
                if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                    SibTr.exception(this, TRACE, exception);
                }
                throw new ResourceAdapterInternalException(NLS
                        .getFormattedMessage(("UNLOCK_EXCEPTION_CWSIV0601"),
                                new Object[] { exception, listOfSIBusMessages }, null),
                        exception);

            }
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
640917
public void unlockSession(HttpSession sess) {
      if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
          LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[UNLOCK_SESSION]);
      }
      SessionData session= (SessionData)sess;
      Object obj = session.getSessionLock(Thread.currentThread());
      if (obj!=null) {
          LinkedList linkList = session.getLockList();
          synchronized(linkList) {
              try {
                  linkList.remove(obj);
                  if (linkList.size()>0) {
                      Object nextLock = linkList.getFirst();
                      if (nextLock !=null) {
                          if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                              LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[UNLOCK_SESSION], "notify after postInvoke");
                          }
                          synchronized(nextLock) {
                              nextLock.notify();
                          }
                      }
                  } else {
                      session.clearSessionLocks();
                  }
              } catch (Exception e) {
                  if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                      LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[UNLOCK_SESSION], "failed to unlock session", e);
                  }
              }
          }
      }                   
      if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
          LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[UNLOCK_SESSION]);
      }
  }