if (request instanceof HttpServletRequest) {
if (request instanceof HttpServletRequest && ((HttpServletRequest) request).isRequestedSessionIdValid()) {
    public void commitToContainer(ServletRequest request,        Authentication authentication) {        if (request instanceof HttpServletRequest) {            HttpSession httpSession = ((HttpServletRequest) request).getSession();            if (httpSession != null) {                httpSession.setAttribute(ACEGI_SECURITY_AUTHENTICATION_KEY,                    authentication);                updateOtherLocations(httpSession, authentication);            }        }    }