Helper method.  Checks if this group has been closed and throws
an exception if it has.
@throws SIIncorrectCallException
332694
private void checkClosed() throws SIIncorrectCallException
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "checkClosed", ""+closed);
      if (closed) 
         throw new SIIncorrectCallException(
            TraceNLS.getFormattedMessage(CommsConstants.MSG_BUNDLE, "PROXY_QUEUE_CONVERSATION_GROUP_CLOSED_SICO1059", null, "PROXY_QUEUE_CONVERSATION_GROUP_CLOSED_SICO1059") // D270373
         );
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "checkClosed");
   }
600587
private ILockableEntityGroup ifindLockableGroup(String key, String lockOwner)
            throws GroupsException {
        return compositeGroupService.findGroupWithLock(key, lockOwner);
    }
1201546
private static boolean closeEventLoopGroupIfNoRef(EventLoopGroup eventLoopGroup) {
        if (eventLoopGroup != null && refCounter.get(eventLoopGroup).decrementAndGet() <= 0) {
            if (!eventLoopGroup.isShuttingDown() && !eventLoopGroup.isShutdown()) {
                eventLoopGroup.shutdownGracefully();
            }
            refCounter.remove(eventLoopGroup);
            return true;
        }
        return false;
    }
180326
public synchronized void onOpen() {
        if (state == State.WAITING || state == State.SCANNING)
            throw new IllegalStateException("Do not call onOpen if not closed before");
        currentDataUsed = true;
        state = State.WAITING;
    }
978338
public boolean handleCloseGroup() {
		this.onCloseGroup();	// event handler
		
		if(this.rtfParser.isImport()) {
			if(this.buffer.length()>0) {
				writeBuffer();
			}
			writeText("}");
		}
		if(this.rtfParser.isConvert()) {
			if(this.buffer.length() > 0 && this.iTextParagraph == null) {
				this.iTextParagraph = new Paragraph();
			}
			if(this.buffer.length() > 0 ) {
				Chunk chunk = new Chunk();
				chunk.append(this.buffer.toString());
				this.iTextParagraph.add(chunk);
			}
			if(this.iTextParagraph != null) {
				addParagraphToDocument();
			}
		}
		return true;
	}
519648
public void sessionClosed(IoSession session) throws Exception {
        SingleSessionIoHandler handler = (SingleSessionIoHandler) session
                .getAttribute(HANDLER);
        handler.sessionClosed();
    }
453434
def end_grouping(self):
        
        close = self._open.pop()
        if not close:
            return
        if self._open:
            self._open[-1].extend(close)
        elif self._undoing:
            self._redo.append(close)
        else:
            self._undo.append(close)
        self.notify()
1281118
void checkClosed() throws FetchException {
        TransactionScope<Txn> scope = localTransactionScope();

        // Lock out shutdown task.
        scope.getLock().lock();
        try {
            if (mPrimaryDatabase == null) {
                // If shutting down, this will force us to block forever.
                try {
                    scope.getTxn();
                } catch (Exception e) {
                    // Don't care.
                }
                // Okay, not shutting down, so throw exception.
                throw new FetchException("Repository closed");
            }
        } finally {
            scope.getLock().unlock();
        }
    }
1076457
public final boolean collapseGroup(final int groupIndex) {
        ExpandableListAdapter adapter = getExpandableListAdapter();

        if (adapter != null && isGroupExpanded(groupIndex)) {
            expandedGroups.remove(groupIndex);
            notifyDataSetChanged();
            return true;
        }

        return false;
    }
663032
public V call() throws Exception {
        if (Tracy.isEnabled(this.tracyWorkerContext))   {
            Tracy.setContext(this.tracyWorkerContext);
        }
        else    {
            Tracy.clearContext();
        }
        return userCallable.call();
    }
156703
@Override
    public void close() throws SIResourceException, SINotPossibleInCurrentConfigurationException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "close", this);

        // On closing, we need to run the async consumer a final time to process
        // any messages it has attached.
        //
        // We need to take the async consumer lock so we don't step on a currently
        // running consumer (so that running asyncs can complete with all their
        // resources available - i.e. without object closed exceptions - as per the
        // JMS 1.1 spec).
        //
        // Taking this lock also prevents other invocations of close which take
        // place before this invocation has completed from proceeding (as per the
        // JMS 1.1 spec).
        //
        // We also taken the consumer session lock for most of the method.  In
        // theory, we could release this lock while running the async consumer,
        // but this makes things a little more complicated and there seems little
        // point when we're closing down anyway.
        //
        // The async consumer could concievably spin forever and prevent the close.
        // This is an accepted fact.

        // We need to get any asynch thread to stop looping round the queue to
        // allow us to have a chance of closing this consumer. We have to do this outside
        // of the asynch lock as that will be held by the other thread at this time.
        _interruptConsumer = true;

        synchronized (_asynchConsumerBusyLock)
        {
            if (_closed || _closing)
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(tc, "close", "Already Closed");
                return;
            }

            _lockRequested = true;

            // Lock the KeyGroup if we have one before we lock this consumer
            if (_keyGroup != null)
                _keyGroup.lock();

            try
            {
                this.lock();
                try
                {
                    _lockRequested = false;

                    _consumerKey.stop();

                    // We don't want new messages to be attached if we're closing.
                    unsetReady();

                    // We need to release the LCP lock while we process attached messages
                    // but first we mark the consumer as closing to stop other calls succeeding
                    _closing = true;
                } finally
                {
                    this.unlock();
                }
            } finally
            {
                if (_keyGroup != null)
                    _keyGroup.unlock();
            }

            // Process any attached messages already on the async consumer.
            if (_asynchConsumerRegistered)
            {
                // If we reach here and an async consumer is running, close() must
                // have been called from the async consumer callback as we have been
                // able to acquire the asynchConsumer lock.
                //
                // Therefore, do not erroneously recursively invoke the callback.
                if (!_asynchConsumer.isAsynchConsumerRunning())
                {
                    try
                    {
                        processAttachedMsgs();
                    } catch (SISessionDroppedException e)
                    {
                        //No FFDC code needed
                        //essentially the session is already closed but we'll try to carry
                        //cleaning up
                    }
                }

                // If we are a member of an ordering group then we need to leave it
                // before we close
                if (_keyGroup != null)
                {
                    _consumerKey.leaveKeyGroup();
                    _keyGroup = null;
                }
            }

            //Now take the lock back and unlock any locked messages and kick out
            // any waiting receiver
            this.lock();
            try
            {
                synchronized (_allLockedMessages)
                {
                    try
                    {
                        // Unlock any remaining locked messages
                        _allLockedMessages.unlockAll();
                    } catch (SIMPMessageNotLockedException e)
                    {
                        // No FFDC code needed
                        // This exception has occurred beause someone has deleted the
                        // message(s). Ignore this exception as it is unlocked anyway
                    } catch (SISessionDroppedException e)
                    {
                        //No FFDC code needed
                        //essentially the session is already closed but we'll try to carry
                        //cleaning up
                    }

                    // Mark this consumer session (point) as closed
                    _closed = true;
                }

                // If we have a synchronous receive we need to wake it up
                if (_waiting)
                {
                    _waiter.signal();
                }
            } // synchronized(this)
            finally
            {
                this.unlock();
            }

            _interruptConsumer = false;

            // If we've managed to interupt another thread that's currently checking for messages
            // to give to a consumer (runAsynchConsumer) then we need to wait until they realise
            // that we've interupted them before we return. Otherwise we'll have a dangling thread
            // that's technically 'working', even though the consumer is closed
            if (_runningAsynchConsumer && !_asynchConsumer.isAsynchConsumerRunning())
            {
                _runAsynchConsumerInterupted = true;
                try
                {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        SibTr.debug(this, tc, "Waiting for runAsynchConsumer to complete");

                    _asynchConsumerBusyLock.wait();
                } catch (InterruptedException e)
                {
                    // No FFDC code needed
                }
            }
        } // synchronized(asynch)

        // Now we no longer hold a lock, unlock any messages we happen
        // to have hidden for this consumer (SIB0115)
        unlockAllHiddenMessages();

        //detach from the CD - we CANNOT hold any consumer locks at this point!
        _consumerKey.detach();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "close");
    }
51303
def maybe_call_closing_deferred(self):
        

        if self._closing_deferred:
            self._closing_deferred.callback(self)
            self._closing_deferred = None
1003562
public void joinGroups(final ArrayList<String> groupIDList, final JoinGroupCompletionListener completionListener) {
        if (isConnected()) {
            if ((groupIDList != null) && (groupIDList.size() > 0)) {
                String urlEndpoint = "/v1/groups";

                JSONArray groupList = new JSONArray(groupIDList);
                JSONObject data = new JSONObject();
                try {
                    data.put("groups", groupList);

                    signalingChannel.sendRESTMessage("post", urlEndpoint, data, new RespokeSignalingChannel.RESTListener() {
                        @Override
                        public void onSuccess(Object response) {
                            final ArrayList<RespokeGroup> newGroupList = new ArrayList<RespokeGroup>();
                            for (String eachGroupID : groupIDList) {
                                RespokeGroup newGroup = new RespokeGroup(eachGroupID, signalingChannel, RespokeClient.this);
                                groups.put(eachGroupID, newGroup);
                                newGroupList.add(newGroup);
                            }

                            new Handler(Looper.getMainLooper()).post(new Runnable() {
                                @Override
                                public void run() {
                                    if (null != completionListener) {
                                        completionListener.onSuccess(newGroupList);
                                    }
                                }
                            });
                        }

                        @Override
                        public void onError(final String errorMessage) {
                            postJoinGroupMembersError(completionListener, errorMessage);
                        }
                    });
                } catch (JSONException e) {
                    postJoinGroupMembersError(completionListener, "Error encoding group list to json");
                }
            } else {
                postJoinGroupMembersError(completionListener, "At least one group must be specified");
            }
        } else {
            postJoinGroupMembersError(completionListener, "Can't complete request when not connected. Please reconnect!");
        }
    }
220643
private void checkReceiveState()
                    throws SIIncorrectCallException, SISessionUnavailableException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "checkReceiveState");

        // Only valid if the consumer session is still open
        checkNotClosed();

        //if there is an AsynchConsumerCallback registered, throw an exception
        if (_asynchConsumerRegistered)
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "checkReceiveState", "asynchConsumerRegistered == true ");

            throw new SIIncorrectCallException(
                            nls.getFormattedMessage(
                                                    "RECEIVE_USAGE_ERROR_CWSIP0171",
                                                    new Object[] { _consumerDispatcher.getDestination().getName(),
                                                                  _messageProcessor.getMessagingEngineName() },
                                                    null));
        }
        // If we already have the waiting bit set it implies another
        // thread is sat waiting in a receive for this consumer (we release
        // the consumer lock while waiting so this is possible).
        else if (_waiting)
        {
            SIIncorrectCallException e =
                            new SIIncorrectCallException(
                                            nls.getFormattedMessage(
                                                                    "RECEIVE_USAGE_ERROR_CWSIP0178",
                                                                    new Object[] { _consumerDispatcher.getDestination().getName(),
                                                                                  _messageProcessor.getMessagingEngineName() },
                                                                    null));

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "checkReceiveState", "receive already in progress");

            throw e;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "checkReceiveState");
    }
603527
public static void closeIgnoringExceptions(AutoCloseable closeable) {
    if (closeable != null) {
      try {
        closeable.close();

        // Suppress it since we ignore any exceptions
        // SUPPRESS CHECKSTYLE IllegalCatch
      } catch (Exception e) {
        // Still log the Exception for issue tracing
        LOG.log(Level.WARNING, String.format("Failed to close %s", closeable), e);
      }
    }
  }
475194
def GetPossibleGroup(self):
    

    # Remove this method from the tail of the queue so we can add it to a group.
    this_method = self._call_queue.pop()
    assert this_method == self

    # Determine if the tail of the queue is a group, or just a regular ordered
    # mock method.
    group = None
    try:
      group = self._call_queue[-1]
    except IndexError:
      pass

    return group
205415
public synchronized void commit()
      throws SIIncorrectCallException, 
             SIRollbackException,
             SIResourceException,
             SIConnectionLostException, 
             SIErrorException
   {
      if (tc.isEntryEnabled()) SibTr.entry(this, tc, "commit");
      
      if (!valid) 
      {
         throw new SIIncorrectCallException(
            nls.getFormattedMessage("TRANSACTION_COMPLETE_SICO1022", null, null)
         );
      }
      
      // Mark this as invalid
      valid = false;
      
      CommsByteBuffer request = getCommsByteBuffer();
      request.putShort(getConnectionObjectID());
      request.putInt(getTransactionId());

      CommsByteBuffer reply = null;
      try
      {
         // Pass on call to server
         reply = jfapExchange(request,
                              JFapChannelConstants.SEG_COMMIT_TRANSACTION,
                              lowestPriority,
                              true);

         short err = reply.getCommandCompletionCode(JFapChannelConstants.SEG_COMMIT_TRANSACTION_R);
         if (err != CommsConstants.SI_NO_EXCEPTION)
         {
            checkFor_SIIncorrectCallException(reply, err);
            checkFor_SIRollbackException(reply, err);
            checkFor_SIResourceException(reply, err);
            checkFor_SIConnectionLostException(reply, err);
            checkFor_SIErrorException(reply, err);
            defaultChecker(reply, err);
         }
      }
      catch (SIConnectionDroppedException e)
      {
         // No FFDC Code needed
         // In this case we translate this to an SIConnectionLostException - as transactions aren't
         // tided to a particular connection
         throw new SIConnectionLostException(e.getMessage(), e);
      }
      finally
      {
         if (reply != null) reply.release();
      }
      
      if (tc.isEntryEnabled()) SibTr.exit(this, tc, "commit");
   }