public synchronized ShareSession remove(ShareSession session) {
        synchronized (session) {
            lastUsed.remove(session.lastUsedKey());
        }
        ShareSession removeResult = sessions.remove(session.key());
        if (removeResult != null) {
            numPartitions = numPartitions - session.cachedSize();
        }
        return removeResult;
    }
Remove an entry from the session cache.

@param session The session.
@return The removed session, or None if there was no such session.
server/src/main/java/org/apache/kafka/server/share/ShareSessionCache.java