shiro使用redis作為緩存,出現要清除緩存時報錯
java.lang.Exception: Failed to deserialize
at org.crazycake.shiro.SerializeUtils.deserialize(SerializeUtils.java:41) ~[shiro-redis-2.4.2.1-RELEASE.jar:na]
at org.crazycake.shiro.RedisSessionDAO.getActiveSessions(RedisSessionDAO.java:66) [shiro-redis-2.4.2.1-RELEASE.jar:na]
因為使用的是
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
<version>2.4.2.1-RELEASE</version>
所以在獲取所有的session中的key來反序列化時出現不能反序列化。
看了了下源碼
然后各種問題搜索,定義問題的出錯在哪,最后發現是使用的
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
<version>2.4.2.1-RELEASE</version>
版本有的漏洞,但是在2.4.6版本的已經修復了這個bug
2.4.6 解決了序列化的問題,請升級至2.4.6。而且被序列化的對象必須實現 java.io.Serializable 接口