public void unregisterIncomingServerSession(@Nonnull final String domain, @Nonnull final LocalIncomingServerSession session)
    {
        final StreamID streamID = session.getStreamID();
        Log.trace("Unregistering incoming server session for domain {} and stream ID {}", domain, streamID);
        final Set<String> remaining = session.getValidatedDomains().stream().filter(d -> !d.equals(domain)).collect(Collectors.toSet());
        final Lock lock = incomingServerSessionInfoCache.getLock(streamID);
        lock.lock();
        try {
            if (!remaining.isEmpty()) {
                Log.trace("Other validated domain(s) remain ({}). Replace the cache entry with an updated entry", String.join(", ", remaining));
                localSessionManager.addIncomingServerSessions(streamID, session);
                incomingServerSessionInfoCache.put(streamID, new IncomingServerSessionInfo(session));
            } else {
                Log.trace("This session does not have any validated domains anymore. Remove it completely.");
                localSessionManager.removeIncomingServerSessions(streamID);
                incomingServerSessionInfoCache.remove(streamID);
            }
        } finally {
            lock.unlock();
        }

        // Update list of sockets/sessions coming from the same remote domain
        CacheUtil.removeValueFromMultiValuedCache(domainSessionsCache, domain, streamID);
    }
Unregisters the specified remote domain that previously originated from the specified session of a remote server.
This will retain a cache entry for the session as long as there is one or more validated domains remain
associated with the session.

@param domain the domain that is no longer being served by the remote server.
@param session the session from which to unregister the domain.
xmppserver/src/main/java/org/jivesoftware/openfire/SessionManager.java