Close a session.

@param session
353537
public static void closeQuietly(final Session session)
    {
        if (session != null) {
            try {
                session.close();
            }
            catch (JMSException je) {
                if (je.getCause() instanceof InterruptedException) {
                    LOG.trace("ActiveMQ caught and wrapped InterruptedException");
                }
                if (je.getCause() instanceof InterruptedIOException) {
                    LOG.trace("ActiveMQ caught and wrapped InterruptedIOException");
                }
                else {
                    LOG.warnDebug(je, "While closing session");
                }
            }
        }
    }
97575
function (session) {

        if (session.websocket.server) session.websocket.server.close();

        session.proxy.close(function (err) {
            console.error('Error: ' + err);
        });
    }
516765
@Override
    public void onClose(Session session, CloseReason closeReason) {
        if (onClose != null) {
            Object args[] = new Object[onClose.getMethod().getParameterTypes().length];
            MethodData methodData = onClose.getMethodData();
            //check if method has optional Session parameter
            int sessionIndex = methodData.getSessionIndex();
            if (sessionIndex >= 0) {
                args[sessionIndex] = session;
            }
            //check if method has optional closeReason parameter
            int reasonIndex = methodData.getCloseReasonIndex();
            if (reasonIndex >= 0) {
                args[reasonIndex] = closeReason;
            }
            if (shouldProcessPath) {
                try {
                    //substitute values for @PathParam values for this method.
                    onClose.processPathParameters(this, args);
                } catch (DecodeException e) {
                    /*
                     * JSR 356 @PathParam section
                     * "If the container cannot decode the path segment appropriately to the annotated path parameter, then the container must raise an DecodeException to the error
                     * handling method of the websocket containing the path segment. [WSC-4.3-6]"
                     * Section
                     * 4.
                     * 5:"If the method itself throws an error, the implementation must pass this error to the onError() method of the endpoint together with the session [WSC-4.5-3]"
                     */
                    this.onError(session, e);
                    return;
                }
            }

            try {
                if (appInstance == null) {
                    if (tc.isDebugEnabled()) {
                        Tr.debug(tc, "application instance is null in onClose");
                    }
                    return;
                }

                onClose.getMethod().invoke(appInstance, args);

            } catch (IllegalAccessException e) {
                //JSR 356 Section 4.5:  "If the method itself throws an error, the implementation
                //must pass this error to the onError() method of the endpoint together with the session [WSC-4.5-3]"
                this.onError(session, e);
            } catch (IllegalArgumentException e) {
                this.onError(session, e);
            } catch (InvocationTargetException e) {
                this.onError(session, e);
            }
        } else { //onClose method is not defined, hence log the problem in trace
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "onClose() is called on Endpoint class: " + sepClass + " which does not have onClose method defined");
            }
        }
    }
914311
def close(self):
        """"""
        if not self.lock_disable and self.session_config_lock:
            self._unlock()
        self.device.close()
805733
protected void onSessionClose(SessionImpl session) {
        Lock lock = lockManager.getLock(getLockingKey(session.keyspace()));
        lock.lock();
        try {
            if (keyspaceCacheMap.containsKey(session.keyspace())) {
                KeyspaceCacheContainer cacheContainer = keyspaceCacheMap.get(session.keyspace());
                cacheContainer.removeSessionReference(session);
                // If there are no more sessions associated to current keyspace,
                // close graph and remove reference from cache.
                if (cacheContainer.referenceCount() == 0) {
                    JanusGraph graph = cacheContainer.graph();
                    graph.close();
                    keyspaceCacheMap.remove(session.keyspace());
                }
            }
        } finally {
            lock.unlock();
        }
    }
514718
private function closeSession(Request $request)
    {
        $session = $request->getSession();

        if ($session && $session->isStarted()) {
            $session->save();
        }
    }
118550
public void complete(Session session) {
        try {
            session.complete();
            sessionCache.put(session.getId(), session);
        } catch (Exception e) {
            log.warn("Session failed to complete", e);
        }
    }
1051243
public void removeHttpSession(final HttpSession session) {
		if (View.isInitialised() && !EventQueue.isDispatchThread()) {
			EventQueue.invokeLater(new Runnable() {

				@Override
				public void run() {
					removeHttpSession(session);
				}
			});

			return;
		}

		int index = sessions.indexOf(session);
		sessions.remove(index);
		fireTableRowsDeleted(index, index);
	}
855089
public void close()
  {
    if (TraceComponent.isAnyTracingEnabled() && CoreSPIBrowserSession.tc.isEntryEnabled())
      SibTr.entry(CoreSPIBrowserSession.tc, "close", this);

    synchronized (this)
    {
      if (!_closed)
        //if we're closed already, don't bother doing anything.
      {
        //dereference from the parent connection
        _conn.removeBrowserSession(this);

        _close();
      }
    }
    if (TraceComponent.isAnyTracingEnabled() && CoreSPIBrowserSession.tc.isEntryEnabled())
      SibTr.exit(CoreSPIBrowserSession.tc, "close");
  }
579612
def close_session(self):
        
        with self._graph.as_default():
            self._sess.close()
            self._sess = None
316369
void connectionCloses(final Session connection) {
        synchronized (connections) {
            final ExecutorService executorService = connectionThreads.get(connection);
            if (executorService != null) {
                executorService.shutdownNow();
            }
            connectionThreads.remove(connection);
            connections.remove(connection);
        }
    }
1157086
private void closeSession(){
        if(LOGGER.isDebugEnabled()){
            LOGGER.debug("Close the session, sessionId=" + session.id + ", timeOut=" + session.timeOut);
        }
        if(! closing && getStatus().isConnected()){
            closing = true;
            if(getStatus().isAlive()){
                setStatus(ConnectionStatus.NOT_CONNECTED);
            }
            cleanupSession();
            closing = false;
        }
    }
13516
protected final void closeSessionAndClearTokenInformation() {
        if (sessionTracker != null) {
            Session currentSession = sessionTracker.getOpenSession();
            if (currentSession != null) {
                currentSession.closeAndClearTokenInformation();
            }
        }
    }
959808
@Override
    public void closeSession(Throwable e) throws SIConnectionLostException, SIResourceException, SIErrorException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "closeSession", e);

        if (e == null)
        {
            //try and build an appropriate exception
            if (_consumerKey.isClosedDueToDelete())
            {
                e = new SISessionDroppedException(
                                nls.getFormattedMessage(
                                                        "DESTINATION_DELETED_ERROR_CWSIP00221",
                                                        new Object[] {
                                                                      _consumerDispatcher.getDestination().getName(),
                                                                      _messageProcessor.getMessagingEngineName() },
                                                        null));
            }
            else if (_consumerKey.isClosedDueToReceiveExclusive())
            {
                e = new SISessionDroppedException(
                                nls.getFormattedMessage(
                                                        "DESTINATION_EXCLUSIVE_ERROR_CWSIP00222",
                                                        new Object[] {
                                                                      _consumerDispatcher.getDestination().getName(),
                                                                      _messageProcessor.getMessagingEngineName() },
                                                        null));
            }
        }

        //and close the session
        _consumerSession.close();

        if (e != null)
            notifyException(e);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "closeSession", e);
    }
914662
public void destroy() {
        JmsUtils.closeSession(session);

        if (connection != null) {
            ConnectionFactoryUtils.releaseConnection(connection, endpointConfiguration.getConnectionFactory(), true);
        }
    }
170870
public void shutdown(){
        transactionListenerSet.forEach(transactionListener -> transactionListener.close(null));
        transactionListenerSet.clear();
        openSessions.values().forEach(SessionImpl::close);
    }
997528
public void disconnect() {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Disconnecting client for session: 0x"
                    + Long.toHexString(getSessionId()));
        }

        sendThread.close();
        eventThread.queueEventOfDeath();
    }