Commit 5b298aa8 authored by 技术部-任文超's avatar 技术部-任文超

优化代码,防止NPE

parent 44c89ead
......@@ -12,6 +12,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
* Created by Miraculous on 2016/12/29.
......@@ -40,7 +41,7 @@ public class XyqbSessionContextHolder {
}
public static SessionStruct getXSessionFromRedis(String token){
if (token == null || token.length() != 36) {
if (Objects.isNull(token) || token.length() != 36 || Objects.isNull(redisTemplate)) {
return null;
}
String result = redisTemplate.opsForValue().get(Constants.Session.USER_SESSION_CACHE + token);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment