Browse Source

修复多线程环境下shiro获取subject的npe,但多次请求数据库取session的“特性”又回来了

NorthLan 6 years ago
parent
commit
aa1dd62394

+ 12 - 11
zen-api/src/main/kotlin/com/gxzc/zen/umps/config/ZenWebSessionManager.kt

@@ -167,16 +167,17 @@ class ZenWebSessionManager : DefaultSessionManager {
             return null
         }
         ////////////////////////Add by noahlan//////////////////////////////////
-        var request: ServletRequest? = null
-        if (sessionKey is WebSessionKey) {
-            request = sessionKey.servletRequest
-        }
-        if (request != null) {
-            val s = request.getAttribute(sessionId.toString())
-            if (s != null) {
-                return s as Session
-            }
-        }
+        // 多线程下request获取不到,凉凉
+//        var request: ServletRequest? = null
+//        if (sessionKey is WebSessionKey) {
+//            request = sessionKey.servletRequest
+//        }
+//        if (request != null) {
+//            val s = request.getAttribute(sessionId.toString())
+//            if (s != null) {
+//                return s as Session
+//            }
+//        }
         ////////////////////////////////////////////////////////////////////////
         val s = retrieveSessionFromDataSource(sessionId)
         if (s == null) {
@@ -186,7 +187,7 @@ class ZenWebSessionManager : DefaultSessionManager {
         }
 
         ////////////////////////Add by noahlan//////////////////////////////////
-        request?.setAttribute(sessionId.toString(), s)
+//        request?.setAttribute(sessionId.toString(), s)
         ///////////////////////////////////////////////////////////////////////
         return s
     }