Closed dngzs closed 4 years ago
目前遇到一个偶发问题,我们redis中key值较多,scan较长时间,等到调用deserialize时,该key值可能已经不存在了,导致了session是个null 然后报NPE了 ,建议还是要优化下代码
好的,我去看看
发自我的iPhone
------------------ 原始邮件 ------------------ 发件人: 不想当厨子的老谭 @.> 发送时间: 2023年4月4日 01:49 收件人: alexxiyang/shiro-redis @.> 抄送: alex @.>, State change @.> 主题: Re: [alexxiyang/shiro-redis] Session s = (Session) valueSerializer.deserialize(redisManager.get(key));为空的问题 (#120)
目前遇到一个偶发问题,我们redis中key值较多,scan较长时间,等到调用deserialize时,该key值可能已经不存在了,导致了session是个null 然后报NPE了 ,建议还是要优化下代码
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>
@alexxiyang 我提了个和并请求 麻烦看下
好的
发自我的iPhone
------------------ 原始邮件 ------------------ 发件人: 不想当厨子的老谭 @.> 发送时间: 2023年4月5日 18:23 收件人: alexxiyang/shiro-redis @.> 抄送: alex @.>, Mention @.> 主题: Re: [alexxiyang/shiro-redis] Session s = (Session) valueSerializer.deserialize(redisManager.get(key));为空的问题 (#120)
@alexxiyang 我提了个和并请求 麻烦看下
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
这段代码我看了下,session可能为空 @Override public Object deserialize(byte[] bytes) throws SerializationException { Object result = null;
这样会有一个问题,在shiro源码中 AbstractValidatingSessionManager#validateSessions中有这么一段代码 Collection activeSessions = getActiveSessions();
.....省略
for(Session s:activeSessions ){
SessionKey key = new DefaultSessionKey(s.getId());
}
s.getId产生空指针,请教下这个能修复下吗?错误堆栈
[DefaultQuartzScheduler_Worker-2] ERROR ErrorLogger:? - Job (DEFAULT.SessionValidationJob threw an exception. org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException] at org.quartz.core.JobRunShell.run(JobRunShell.java:213) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525) Caused by: java.lang.NullPointerException at org.apache.shiro.session.mgt.AbstractValidatingSessionManager.validateSessions(AbstractValidatingSessionManager.java:287) at org.apache.shiro.session.mgt.quartz.QuartzSessionValidationJob.execute(QuartzSessionValidationJob.java:80) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) ... 1 more