You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by bd...@apache.org on 2016/08/09 14:08:14 UTC
shiro git commit: SHIRO-577 Fixes bug allow enabling of
SessionValidationScheduler when set via setSessionValidationScheduler
Repository: shiro
Updated Branches:
refs/heads/1.3.x a4b5f418c -> c7e0f854c
SHIRO-577 Fixes bug allow enabling of SessionValidationScheduler when set via setSessionValidationScheduler
If a SessionValidationScheduler was set via sessionManager.setSessionValidationScheduler, instead of using the
default creation of the object in enableSessionValidation, the SessionValidationScheduler would not be enabled.
Project: http://git-wip-us.apache.org/repos/asf/shiro/repo
Commit: http://git-wip-us.apache.org/repos/asf/shiro/commit/c7e0f854
Tree: http://git-wip-us.apache.org/repos/asf/shiro/tree/c7e0f854
Diff: http://git-wip-us.apache.org/repos/asf/shiro/diff/c7e0f854
Branch: refs/heads/1.3.x
Commit: c7e0f854caa6e0ab7d9f0508fb580a59dce49436
Parents: a4b5f41
Author: Brian Demers <bd...@apache.org>
Authored: Fri Jul 29 12:13:46 2016 -0400
Committer: Brian Demers <bd...@apache.org>
Committed: Fri Jul 29 12:13:46 2016 -0400
----------------------------------------------------------------------
.../mgt/AbstractValidatingSessionManager.java | 4 ++++
.../session/mgt/DefaultSessionManagerTest.java | 25 ++++++++++++++++++++
2 files changed, 29 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/shiro/blob/c7e0f854/core/src/main/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManager.java b/core/src/main/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManager.java
index 6c59d77..cdfeded 100644
--- a/core/src/main/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManager.java
+++ b/core/src/main/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManager.java
@@ -225,6 +225,10 @@ public abstract class AbstractValidatingSessionManager extends AbstractNativeSes
if (scheduler == null) {
scheduler = createSessionValidationScheduler();
setSessionValidationScheduler(scheduler);
+ }
+ // it is possible that that a scheduler was already created and set via 'setSessionValidationScheduler()'
+ // but would not have been enabled/started yet
+ if (!scheduler.isEnabled()) {
if (log.isInfoEnabled()) {
log.info("Enabling session validation scheduler...");
}
http://git-wip-us.apache.org/repos/asf/shiro/blob/c7e0f854/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java b/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java
index 9723146..8dd5975 100644
--- a/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java
+++ b/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java
@@ -192,6 +192,31 @@ public class DefaultSessionManagerTest {
verify(sessionDAO); //verify that the delete call was actually made on the DAO
}
+ /**
+ * Tests a bug introduced by SHIRO-443, where a custom sessionValidationScheduler would not be started.
+ */
+ @Test
+ public void testEnablingOfCustomSessionValidationScheduler() {
+
+ // using the default impl of sessionValidationScheduler, as the but effects any scheduler we set directly via
+ // sessionManager.setSessionValidationScheduler(), commonly used in INI configuration.
+ ExecutorServiceSessionValidationScheduler sessionValidationScheduler = new ExecutorServiceSessionValidationScheduler();
+ DefaultSessionManager sessionManager = new DefaultSessionManager();
+ sessionManager.setSessionValidationScheduler(sessionValidationScheduler);
+
+ // starting a session will trigger the starting of the validator
+ try {
+ Session session = sessionManager.start(null);
+
+ // now sessionValidationScheduler should be enabled
+ assertTrue("sessionValidationScheduler was not enabled", sessionValidationScheduler.isEnabled());
+ }
+ finally {
+ // cleanup after test
+ sessionManager.destroy();
+ }
+ }
+
public static <T extends Session> T eqSessionTimeout(long timeout) {
EasyMock.reportMatcher(new SessionTimeoutMatcher(timeout));
return null;