定时器, 获取token 导致的 httpRequest为null. 出现的空指针问题
This commit is contained in:
parent
5966258bff
commit
a0fef83bf3
@ -116,7 +116,8 @@ public class RedisPermissionUtils {
|
||||
* @return
|
||||
*/
|
||||
private static String getRedisStringValue(String key) {
|
||||
return String.valueOf(getRedisObjectValue(key));
|
||||
Object obj = getRedisObjectValue(key);
|
||||
return ObjectUtils.isEmpty(obj) ? "" : String.valueOf(obj);
|
||||
}
|
||||
|
||||
/***
|
||||
|
||||
@ -42,10 +42,13 @@ public class SpringUtil implements ApplicationContextAware {
|
||||
}
|
||||
|
||||
public static String getToken() {
|
||||
String authorization = getRequest().getHeader(HDConstant.AUTHORIZATION_KEY);
|
||||
HttpServletRequest request = getRequest();
|
||||
if(request != null){
|
||||
String authorization = request.getHeader(HDConstant.AUTHORIZATION_KEY);
|
||||
if (StringUtils.hasLength(authorization) && authorization.contains(HDConstant.JWT_PREFIX)) {
|
||||
return authorization.substring(HDConstant.JWT_PREFIX.length());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user