Polish contribution

Resolves: #1250
This commit is contained in:
Vedran Pavic
2018-11-02 22:26:17 +01:00
parent 695f2f1509
commit d245cc1a36
2 changed files with 21 additions and 9 deletions

View File

@@ -75,6 +75,7 @@ import org.springframework.session.SessionRepository;
* @param <S> the {@link ExpiringSession} type.
* @since 1.0
* @author Rob Winch
* @author Josh Cummings
*/
@Order(SessionRepositoryFilter.DEFAULT_ORDER)
public class SessionRepositoryFilter<S extends ExpiringSession>
@@ -427,21 +428,31 @@ public class SessionRepositoryFilter<S extends ExpiringSession>
}
}
private final class SessionCommittingRequestDispatcher implements RequestDispatcher {
/**
* Ensures session is committed before issuing an include.
*
* @since 1.3.4
*/
private final class SessionCommittingRequestDispatcher
implements RequestDispatcher {
private final RequestDispatcher delegate;
SessionCommittingRequestDispatcher(RequestDispatcher delegate) {
this.delegate = delegate;
}
public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException {
public void forward(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
this.delegate.forward(request, response);
}
public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException {
public void include(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
SessionRepositoryRequestWrapper.this.commitSession();
this.delegate.include(request, response);
}
}
}

View File

@@ -1175,17 +1175,18 @@ public class SessionRepositoryFilterTests {
});
}
@Test
@Test // gh-1243
public void doFilterInclude() throws Exception {
doFilter(new DoInFilter() {
@Override
public void doFilter(HttpServletRequest wrappedRequest,
HttpServletResponse wrappedResponse) throws IOException, ServletException {
HttpServletResponse wrappedResponse)
throws IOException, ServletException {
String id = wrappedRequest.getSession().getId();
wrappedRequest.getRequestDispatcher("/").include(wrappedRequest, wrappedResponse);
assertThat(
SessionRepositoryFilterTests.this.sessionRepository.getSession(id))
.isNotNull();
wrappedRequest.getRequestDispatcher("/").include(wrappedRequest,
wrappedResponse);
assertThat(SessionRepositoryFilterTests.this.sessionRepository
.getSession(id)).isNotNull();
}
});
}