File tree 2 files changed +25
-3
lines changed
main/java/org/springframework/session/web/http
test/java/org/springframework/session/web/http 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2014-2016 the original author or authors.
2
+ * Copyright 2014-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -289,9 +289,10 @@ public String changeSessionId() {
289
289
setCurrentSession (null );
290
290
291
291
HttpSessionWrapper newSession = getSession ();
292
+ int originalMaxInactiveInterval = session .getMaxInactiveInterval ();
292
293
original .setSession (newSession .getSession ());
293
294
294
- newSession .setMaxInactiveInterval (session . getMaxInactiveInterval () );
295
+ newSession .setMaxInactiveInterval (originalMaxInactiveInterval );
295
296
for (Map .Entry <String , Object > attr : attrs .entrySet ()) {
296
297
String attrName = attr .getKey ();
297
298
Object attrValue = attr .getValue ();
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2014-2016 the original author or authors.
2
+ * Copyright 2014-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -568,6 +568,27 @@ public void doFilter(HttpServletRequest wrappedRequest) {
568
568
});
569
569
}
570
570
571
+ // gh-951
572
+ @ Test
573
+ public void doFilterChangeSessionIdCopyAttributes () throws Exception {
574
+ // change the session id
575
+ doFilter (new DoInFilter () {
576
+ @ Override
577
+ public void doFilter (HttpServletRequest wrappedRequest ) {
578
+ HttpSession session = wrappedRequest .getSession ();
579
+ session .setMaxInactiveInterval (300 );
580
+ String originalSessionId = session .getId ();
581
+ int originalMaxInactiveInterval = session .getMaxInactiveInterval ();
582
+
583
+ String changeSessionId = ReflectionTestUtils .invokeMethod (wrappedRequest ,
584
+ "changeSessionId" );
585
+ assertThat (changeSessionId ).isNotEqualTo (originalSessionId );
586
+ assertThat (session .getMaxInactiveInterval ())
587
+ .isEqualTo (originalMaxInactiveInterval );
588
+ }
589
+ });
590
+ }
591
+
571
592
// gh-142, gh-153
572
593
@ Test
573
594
public void doFilterIsRequestedValidSessionFalseInvalidId () throws Exception {
You can’t perform that action at this time.
0 commit comments