移除多余的if else

pull/285/head
Hacker 2021-04-25 16:49:40 +08:00
parent d0401944ea
commit 7648eab19f
1 changed files with 3 additions and 13 deletions

View File

@ -94,18 +94,8 @@ public class KickoutSessionFilter extends AccessControlFilter
// 如果队列里的sessionId数超出最大会话数开始踢人
while (deque.size() > maxSession)
{
Serializable kickoutSessionId = null;
// 是否踢出后来登录的默认是false即后者登录的用户踢出前者登录的用户
if (kickoutAfter)
{
// 踢出后者
kickoutSessionId = deque.removeFirst();
}
else
{
// 踢出前者
kickoutSessionId = deque.removeLast();
}
Serializable kickoutSessionId = kickoutAfter ? deque.removeFirst() : deque.removeLast();
// 踢出后再更新下缓存队列
cache.put(loginName, deque);
@ -126,7 +116,7 @@ public class KickoutSessionFilter extends AccessControlFilter
}
// 如果被踢出了,(前者或后者)直接退出,重定向到踢出后的地址
if ((Boolean) session.getAttribute("kickout") != null && (Boolean) session.getAttribute("kickout") == true)
if (session.getAttribute("kickout") != null && (Boolean) session.getAttribute("kickout") == true)
{
// 退出登录
subject.logout();
@ -183,4 +173,4 @@ public class KickoutSessionFilter extends AccessControlFilter
// 必须和ehcache缓存配置中的缓存name一致
this.cache = cacheManager.getCache(ShiroConstants.SYS_USERCACHE);
}
}
}