protected Session beforeInvalidNotification(Session session) {
        return new ImmutableProxiedSession(session);
    }
Returns the session instance to use to pass to registered {@code SessionListener}s for notification
that the session has been invalidated (stopped or expired).
<p/>
The default implementation returns an {@link ImmutableProxiedSession ImmutableProxiedSession} instance to ensure
that the specified {@code session} argument is not modified by any listeners.

@param session the {@code Session} object being invalidated.
@return the {@code Session} instance to use to pass to registered {@code SessionListener}s for notification.
core/src/main/java/org/apache/shiro/session/mgt/AbstractNativeSessionManager.java