diff --git a/spring-session-core/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java b/spring-session-core/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java index a13f6daf..2833a301 100644 --- a/spring-session-core/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java +++ b/spring-session-core/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2018 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,7 +126,6 @@ public class SpringHttpSessionConfiguration implements ApplicationContextAware { SessionRepository sessionRepository) { SessionRepositoryFilter sessionRepositoryFilter = new SessionRepositoryFilter<>( sessionRepository); - sessionRepositoryFilter.setServletContext(this.servletContext); sessionRepositoryFilter.setHttpSessionIdResolver(this.httpSessionIdResolver); return sessionRepositoryFilter; } diff --git a/spring-session-core/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java b/spring-session-core/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java index ce7cd842..f6d13640 100644 --- a/spring-session-core/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java +++ b/spring-session-core/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2018 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,8 +106,6 @@ public class SessionRepositoryFilter extends OncePerRequestFi private final SessionRepository sessionRepository; - private ServletContext servletContext; - private HttpSessionIdResolver httpSessionIdResolver = new CookieHttpSessionIdResolver(); /** @@ -143,7 +141,7 @@ public class SessionRepositoryFilter extends OncePerRequestFi request.setAttribute(SESSION_REPOSITORY_ATTR, this.sessionRepository); SessionRepositoryRequestWrapper wrappedRequest = new SessionRepositoryRequestWrapper( - request, response, this.servletContext); + request, response); SessionRepositoryResponseWrapper wrappedResponse = new SessionRepositoryResponseWrapper( wrappedRequest, response); @@ -155,10 +153,6 @@ public class SessionRepositoryFilter extends OncePerRequestFi } } - public void setServletContext(ServletContext servletContext) { - this.servletContext = servletContext; - } - /** * Allows ensuring that the session is saved if the response is committed. * @@ -203,8 +197,6 @@ public class SessionRepositoryFilter extends OncePerRequestFi private final HttpServletResponse response; - private final ServletContext servletContext; - private S requestedSession; private boolean requestedSessionCached; @@ -216,10 +208,9 @@ public class SessionRepositoryFilter extends OncePerRequestFi private boolean requestedSessionInvalidated; private SessionRepositoryRequestWrapper(HttpServletRequest request, - HttpServletResponse response, ServletContext servletContext) { + HttpServletResponse response) { super(request); this.response = response; - this.servletContext = servletContext; } /** @@ -340,15 +331,6 @@ public class SessionRepositoryFilter extends OncePerRequestFi return currentSession; } - @Override - public ServletContext getServletContext() { - if (this.servletContext != null) { - return this.servletContext; - } - // Servlet 3.0+ - return super.getServletContext(); - } - @Override public HttpSessionWrapper getSession() { return getSession(true); diff --git a/spring-session-core/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java b/spring-session-core/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java index 36e9c60f..beb61ee8 100644 --- a/spring-session-core/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java +++ b/spring-session-core/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2018 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,6 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.mock.web.MockFilterChain; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockServletContext; import org.springframework.session.MapSession; import org.springframework.session.MapSessionRepository; import org.springframework.session.Session; @@ -240,22 +239,6 @@ public class SessionRepositoryFilterTests { }); } - // gh-111 - @Test - public void doFilterServletContextExplicit() throws Exception { - final ServletContext expectedContext = new MockServletContext(); - this.filter = new SessionRepositoryFilter<>(this.sessionRepository); - this.filter.setServletContext(expectedContext); - - doFilter(new DoInFilter() { - @Override - public void doFilter(HttpServletRequest wrappedRequest) { - ServletContext context = wrappedRequest.getSession().getServletContext(); - assertThat(context).isSameAs(expectedContext); - } - }); - } - @Test public void doFilterMaxInactiveIntervalDefault() throws Exception { doFilter(new DoInFilter() {