Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_57962205
redisson
提交
4b023aa3
R
redisson
项目概览
weixin_57962205
/
redisson
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redisson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4b023aa3
编写于
3月 28, 2019
作者:
N
Nikita Koksharov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed - Tomcat Session Manager doesn't remove session attributes in updateMode=AFTER_REQUEST. #1971
上级
d75f6102
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
153 addition
and
104 deletion
+153
-104
redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/AttributeRemoveMessage.java
...main/java/org/redisson/tomcat/AttributeRemoveMessage.java
+7
-5
redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSession.java
...-6/src/main/java/org/redisson/tomcat/RedissonSession.java
+23
-1
redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
...main/java/org/redisson/tomcat/RedissonSessionManager.java
+8
-6
redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/UpdateValve.java
...mcat-6/src/main/java/org/redisson/tomcat/UpdateValve.java
+0
-14
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/AttributeRemoveMessage.java
...main/java/org/redisson/tomcat/AttributeRemoveMessage.java
+7
-5
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java
...-7/src/main/java/org/redisson/tomcat/RedissonSession.java
+23
-1
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
...main/java/org/redisson/tomcat/RedissonSessionManager.java
+8
-6
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/UpdateValve.java
...mcat-7/src/main/java/org/redisson/tomcat/UpdateValve.java
+0
-14
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/AttributeRemoveMessage.java
...main/java/org/redisson/tomcat/AttributeRemoveMessage.java
+7
-5
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java
...-8/src/main/java/org/redisson/tomcat/RedissonSession.java
+23
-1
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
...main/java/org/redisson/tomcat/RedissonSessionManager.java
+8
-6
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/UpdateValve.java
...mcat-8/src/main/java/org/redisson/tomcat/UpdateValve.java
+0
-14
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/AttributeRemoveMessage.java
...main/java/org/redisson/tomcat/AttributeRemoveMessage.java
+7
-5
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java
...-9/src/main/java/org/redisson/tomcat/RedissonSession.java
+24
-1
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
...main/java/org/redisson/tomcat/RedissonSessionManager.java
+8
-6
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/UpdateValve.java
...mcat-9/src/main/java/org/redisson/tomcat/UpdateValve.java
+0
-14
未找到文件。
redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/AttributeRemoveMessage.java
浏览文件 @
4b023aa3
...
...
@@ -15,6 +15,8 @@
*/
package
org.redisson.tomcat
;
import
java.util.Set
;
/**
*
* @author Nikita Koksharov
...
...
@@ -22,19 +24,19 @@ package org.redisson.tomcat;
*/
public
class
AttributeRemoveMessage
extends
AttributeMessage
{
private
S
tring
name
;
private
S
et
<
String
>
names
;
public
AttributeRemoveMessage
()
{
super
();
}
public
AttributeRemoveMessage
(
String
nodeId
,
String
sessionId
,
S
tring
name
)
{
public
AttributeRemoveMessage
(
String
nodeId
,
String
sessionId
,
S
et
<
String
>
names
)
{
super
(
nodeId
,
sessionId
);
this
.
name
=
name
;
this
.
name
s
=
names
;
}
public
S
tring
getName
()
{
return
name
;
public
S
et
<
String
>
getNames
()
{
return
name
s
;
}
}
redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSession.java
浏览文件 @
4b023aa3
...
...
@@ -25,6 +25,7 @@ import java.util.HashSet;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.catalina.session.StandardSession
;
...
...
@@ -59,6 +60,8 @@ public class RedissonSession extends StandardSession {
private
final
RedissonSessionManager
.
ReadMode
readMode
;
private
final
UpdateMode
updateMode
;
private
Set
<
String
>
removedAttributes
;
public
RedissonSession
(
RedissonSessionManager
manager
,
ReadMode
readMode
,
UpdateMode
updateMode
)
{
super
(
manager
);
this
.
redissonManager
=
manager
;
...
...
@@ -66,6 +69,10 @@ public class RedissonSession extends StandardSession {
this
.
updateMode
=
updateMode
;
this
.
topic
=
redissonManager
.
getTopic
();
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
=
Collections
.
newSetFromMap
(
new
ConcurrentHashMap
<
String
,
Boolean
>());
}
try
{
Field
attr
=
StandardSession
.
class
.
getDeclaredField
(
"attributes"
);
attrs
=
(
Map
<
String
,
Object
>)
attr
.
get
(
this
);
...
...
@@ -257,6 +264,9 @@ public class RedissonSession extends StandardSession {
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
&&
value
!=
null
)
{
fastPut
(
name
,
value
);
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
.
remove
(
name
);
}
}
public
void
superRemoveAttributeInternal
(
String
name
,
boolean
notify
)
{
...
...
@@ -270,9 +280,12 @@ public class RedissonSession extends StandardSession {
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
)
{
map
.
fastRemove
(
name
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
n
ame
));
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
n
ew
HashSet
<
String
>(
Arrays
.
asList
(
name
))
));
}
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
.
add
(
name
);
}
}
public
void
save
()
{
...
...
@@ -295,9 +308,18 @@ public class RedissonSession extends StandardSession {
}
map
.
putAll
(
newMap
);
map
.
fastRemove
(
removedAttributes
.
toArray
(
new
String
[
removedAttributes
.
size
()]));
if
(
readMode
==
ReadMode
.
MEMORY
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
if
(!
removedAttributes
.
isEmpty
())
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
removedAttributes
));
}
}
}
removedAttributes
.
clear
();
expireSession
();
}
...
...
redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
浏览文件 @
4b023aa3
...
...
@@ -260,7 +260,9 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
RedissonSession
session
=
(
RedissonSession
)
RedissonSessionManager
.
super
.
findSession
(
msg
.
getSessionId
());
if
(
session
!=
null
&&
!
msg
.
getNodeId
().
equals
(
nodeId
))
{
if
(
msg
instanceof
AttributeRemoveMessage
)
{
session
.
superRemoveAttributeInternal
(((
AttributeRemoveMessage
)
msg
).
getName
(),
true
);
for
(
String
name
:
((
AttributeRemoveMessage
)
msg
).
getNames
())
{
session
.
superRemoveAttributeInternal
(
name
,
true
);
}
}
if
(
msg
instanceof
AttributesClearMessage
)
{
...
...
@@ -332,11 +334,11 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
return
;
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
RedissonSession
sess
=
(
RedissonSession
)
super
.
findSession
(
session
.
getId
());
if
(
sess
!=
null
)
{
sess
.
save
();
}
RedissonSession
sess
=
(
RedissonSession
)
super
.
findSession
(
session
.
getId
());
if
(
sess
!=
null
)
{
sess
.
access
();
sess
.
endAccess
();
sess
.
save
();
}
}
...
...
redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/UpdateValve.java
浏览文件 @
4b023aa3
...
...
@@ -19,7 +19,6 @@ import java.io.IOException;
import
javax.servlet.ServletException
;
import
org.apache.catalina.Session
;
import
org.apache.catalina.connector.Request
;
import
org.apache.catalina.connector.Response
;
import
org.apache.catalina.valves.ValveBase
;
...
...
@@ -41,19 +40,6 @@ public class UpdateValve extends ValveBase {
@Override
public
void
invoke
(
Request
request
,
Response
response
)
throws
IOException
,
ServletException
{
String
sessionId
=
request
.
getRequestedSessionId
();
Session
session
=
request
.
getContext
().
getManager
().
findSession
(
sessionId
);
if
(
session
!=
null
)
{
if
(!
session
.
isValid
())
{
session
.
expire
();
request
.
getContext
().
getManager
().
remove
(
session
);
}
else
{
manager
.
add
(
session
);
session
.
access
();
session
.
endAccess
();
}
}
try
{
getNext
().
invoke
(
request
,
response
);
}
finally
{
...
...
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/AttributeRemoveMessage.java
浏览文件 @
4b023aa3
...
...
@@ -15,6 +15,8 @@
*/
package
org.redisson.tomcat
;
import
java.util.Set
;
/**
*
* @author Nikita Koksharov
...
...
@@ -22,19 +24,19 @@ package org.redisson.tomcat;
*/
public
class
AttributeRemoveMessage
extends
AttributeMessage
{
private
S
tring
name
;
private
S
et
<
String
>
names
;
public
AttributeRemoveMessage
()
{
super
();
}
public
AttributeRemoveMessage
(
String
nodeId
,
String
sessionId
,
S
tring
name
)
{
public
AttributeRemoveMessage
(
String
nodeId
,
String
sessionId
,
S
et
<
String
>
names
)
{
super
(
nodeId
,
sessionId
);
this
.
name
=
name
;
this
.
name
s
=
names
;
}
public
S
tring
getName
()
{
return
name
;
public
S
et
<
String
>
getNames
()
{
return
name
s
;
}
}
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java
浏览文件 @
4b023aa3
...
...
@@ -25,6 +25,7 @@ import java.util.HashSet;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.catalina.session.StandardSession
;
...
...
@@ -59,6 +60,8 @@ public class RedissonSession extends StandardSession {
private
final
RedissonSessionManager
.
ReadMode
readMode
;
private
final
UpdateMode
updateMode
;
private
Set
<
String
>
removedAttributes
;
public
RedissonSession
(
RedissonSessionManager
manager
,
RedissonSessionManager
.
ReadMode
readMode
,
UpdateMode
updateMode
)
{
super
(
manager
);
this
.
redissonManager
=
manager
;
...
...
@@ -66,6 +69,10 @@ public class RedissonSession extends StandardSession {
this
.
updateMode
=
updateMode
;
this
.
topic
=
redissonManager
.
getTopic
();
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
=
Collections
.
newSetFromMap
(
new
ConcurrentHashMap
<
String
,
Boolean
>());
}
try
{
Field
attr
=
StandardSession
.
class
.
getDeclaredField
(
"attributes"
);
attrs
=
(
Map
<
String
,
Object
>)
attr
.
get
(
this
);
...
...
@@ -257,6 +264,9 @@ public class RedissonSession extends StandardSession {
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
&&
value
!=
null
)
{
fastPut
(
name
,
value
);
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
.
remove
(
name
);
}
}
public
void
superRemoveAttributeInternal
(
String
name
,
boolean
notify
)
{
...
...
@@ -270,9 +280,12 @@ public class RedissonSession extends StandardSession {
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
)
{
map
.
fastRemove
(
name
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
n
ame
));
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
n
ew
HashSet
<
String
>(
Arrays
.
asList
(
name
))
));
}
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
.
add
(
name
);
}
}
public
void
save
()
{
...
...
@@ -295,9 +308,18 @@ public class RedissonSession extends StandardSession {
}
map
.
putAll
(
newMap
);
map
.
fastRemove
(
removedAttributes
.
toArray
(
new
String
[
removedAttributes
.
size
()]));
if
(
readMode
==
ReadMode
.
MEMORY
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
if
(!
removedAttributes
.
isEmpty
())
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
removedAttributes
));
}
}
}
removedAttributes
.
clear
();
expireSession
();
}
...
...
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
浏览文件 @
4b023aa3
...
...
@@ -240,7 +240,9 @@ public class RedissonSessionManager extends ManagerBase {
RedissonSession
session
=
(
RedissonSession
)
RedissonSessionManager
.
super
.
findSession
(
msg
.
getSessionId
());
if
(
session
!=
null
&&
!
msg
.
getNodeId
().
equals
(
nodeId
))
{
if
(
msg
instanceof
AttributeRemoveMessage
)
{
session
.
superRemoveAttributeInternal
(((
AttributeRemoveMessage
)
msg
).
getName
(),
true
);
for
(
String
name
:
((
AttributeRemoveMessage
)
msg
).
getNames
())
{
session
.
superRemoveAttributeInternal
(
name
,
true
);
}
}
if
(
msg
instanceof
AttributesClearMessage
)
{
...
...
@@ -315,11 +317,11 @@ public class RedissonSessionManager extends ManagerBase {
return
;
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
RedissonSession
sess
=
(
RedissonSession
)
super
.
findSession
(
session
.
getId
());
if
(
sess
!=
null
)
{
sess
.
save
();
}
RedissonSession
sess
=
(
RedissonSession
)
super
.
findSession
(
session
.
getId
());
if
(
sess
!=
null
)
{
sess
.
access
();
sess
.
endAccess
();
sess
.
save
();
}
}
...
...
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/UpdateValve.java
浏览文件 @
4b023aa3
...
...
@@ -19,7 +19,6 @@ import java.io.IOException;
import
javax.servlet.ServletException
;
import
org.apache.catalina.Session
;
import
org.apache.catalina.connector.Request
;
import
org.apache.catalina.connector.Response
;
import
org.apache.catalina.valves.ValveBase
;
...
...
@@ -41,19 +40,6 @@ public class UpdateValve extends ValveBase {
@Override
public
void
invoke
(
Request
request
,
Response
response
)
throws
IOException
,
ServletException
{
String
sessionId
=
request
.
getRequestedSessionId
();
Session
session
=
request
.
getContext
().
getManager
().
findSession
(
sessionId
);
if
(
session
!=
null
)
{
if
(!
session
.
isValid
())
{
session
.
expire
();
request
.
getContext
().
getManager
().
remove
(
session
);
}
else
{
manager
.
add
(
session
);
session
.
access
();
session
.
endAccess
();
}
}
try
{
getNext
().
invoke
(
request
,
response
);
}
finally
{
...
...
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/AttributeRemoveMessage.java
浏览文件 @
4b023aa3
...
...
@@ -15,6 +15,8 @@
*/
package
org.redisson.tomcat
;
import
java.util.Set
;
/**
*
* @author Nikita Koksharov
...
...
@@ -22,19 +24,19 @@ package org.redisson.tomcat;
*/
public
class
AttributeRemoveMessage
extends
AttributeMessage
{
private
S
tring
name
;
private
S
et
<
String
>
names
;
public
AttributeRemoveMessage
()
{
super
();
}
public
AttributeRemoveMessage
(
String
nodeId
,
String
sessionId
,
S
tring
name
)
{
public
AttributeRemoveMessage
(
String
nodeId
,
String
sessionId
,
S
et
<
String
>
names
)
{
super
(
nodeId
,
sessionId
);
this
.
name
=
name
;
this
.
name
s
=
names
;
}
public
S
tring
getName
()
{
return
name
;
public
S
et
<
String
>
getNames
()
{
return
name
s
;
}
}
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java
浏览文件 @
4b023aa3
...
...
@@ -25,6 +25,7 @@ import java.util.HashSet;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.catalina.session.StandardSession
;
...
...
@@ -59,6 +60,8 @@ public class RedissonSession extends StandardSession {
private
final
RedissonSessionManager
.
ReadMode
readMode
;
private
final
UpdateMode
updateMode
;
private
Set
<
String
>
removedAttributes
;
public
RedissonSession
(
RedissonSessionManager
manager
,
RedissonSessionManager
.
ReadMode
readMode
,
UpdateMode
updateMode
)
{
super
(
manager
);
this
.
redissonManager
=
manager
;
...
...
@@ -66,6 +69,10 @@ public class RedissonSession extends StandardSession {
this
.
updateMode
=
updateMode
;
this
.
topic
=
redissonManager
.
getTopic
();
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
=
Collections
.
newSetFromMap
(
new
ConcurrentHashMap
<
String
,
Boolean
>());
}
try
{
Field
attr
=
StandardSession
.
class
.
getDeclaredField
(
"attributes"
);
attrs
=
(
Map
<
String
,
Object
>)
attr
.
get
(
this
);
...
...
@@ -257,6 +264,9 @@ public class RedissonSession extends StandardSession {
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
&&
value
!=
null
)
{
fastPut
(
name
,
value
);
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
.
remove
(
name
);
}
}
public
void
superRemoveAttributeInternal
(
String
name
,
boolean
notify
)
{
...
...
@@ -270,9 +280,12 @@ public class RedissonSession extends StandardSession {
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
)
{
map
.
fastRemove
(
name
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
n
ame
));
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
n
ew
HashSet
<
String
>(
Arrays
.
asList
(
name
))
));
}
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
.
add
(
name
);
}
}
public
void
save
()
{
...
...
@@ -295,9 +308,18 @@ public class RedissonSession extends StandardSession {
}
map
.
putAll
(
newMap
);
map
.
fastRemove
(
removedAttributes
.
toArray
(
new
String
[
removedAttributes
.
size
()]));
if
(
readMode
==
ReadMode
.
MEMORY
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
if
(!
removedAttributes
.
isEmpty
())
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
removedAttributes
));
}
}
}
removedAttributes
.
clear
();
expireSession
();
}
...
...
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
浏览文件 @
4b023aa3
...
...
@@ -239,7 +239,9 @@ public class RedissonSessionManager extends ManagerBase {
RedissonSession
session
=
(
RedissonSession
)
RedissonSessionManager
.
super
.
findSession
(
msg
.
getSessionId
());
if
(
session
!=
null
&&
!
msg
.
getNodeId
().
equals
(
nodeId
))
{
if
(
msg
instanceof
AttributeRemoveMessage
)
{
session
.
superRemoveAttributeInternal
(((
AttributeRemoveMessage
)
msg
).
getName
(),
true
);
for
(
String
name
:
((
AttributeRemoveMessage
)
msg
).
getNames
())
{
session
.
superRemoveAttributeInternal
(
name
,
true
);
}
}
if
(
msg
instanceof
AttributesClearMessage
)
{
...
...
@@ -314,11 +316,11 @@ public class RedissonSessionManager extends ManagerBase {
return
;
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
RedissonSession
sess
=
(
RedissonSession
)
super
.
findSession
(
session
.
getId
());
if
(
sess
!=
null
)
{
sess
.
save
();
}
RedissonSession
sess
=
(
RedissonSession
)
super
.
findSession
(
session
.
getId
());
if
(
sess
!=
null
)
{
sess
.
access
();
sess
.
endAccess
();
sess
.
save
();
}
}
...
...
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/UpdateValve.java
浏览文件 @
4b023aa3
...
...
@@ -19,7 +19,6 @@ import java.io.IOException;
import
javax.servlet.ServletException
;
import
org.apache.catalina.Session
;
import
org.apache.catalina.connector.Request
;
import
org.apache.catalina.connector.Response
;
import
org.apache.catalina.valves.ValveBase
;
...
...
@@ -41,19 +40,6 @@ public class UpdateValve extends ValveBase {
@Override
public
void
invoke
(
Request
request
,
Response
response
)
throws
IOException
,
ServletException
{
String
sessionId
=
request
.
getRequestedSessionId
();
Session
session
=
request
.
getContext
().
getManager
().
findSession
(
sessionId
);
if
(
session
!=
null
)
{
if
(!
session
.
isValid
())
{
session
.
expire
();
request
.
getContext
().
getManager
().
remove
(
session
);
}
else
{
manager
.
add
(
session
);
session
.
access
();
session
.
endAccess
();
}
}
try
{
getNext
().
invoke
(
request
,
response
);
}
finally
{
...
...
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/AttributeRemoveMessage.java
浏览文件 @
4b023aa3
...
...
@@ -15,6 +15,8 @@
*/
package
org.redisson.tomcat
;
import
java.util.Set
;
/**
*
* @author Nikita Koksharov
...
...
@@ -22,19 +24,19 @@ package org.redisson.tomcat;
*/
public
class
AttributeRemoveMessage
extends
AttributeMessage
{
private
S
tring
name
;
private
S
et
<
String
>
names
;
public
AttributeRemoveMessage
()
{
super
();
}
public
AttributeRemoveMessage
(
String
nodeId
,
String
sessionId
,
S
tring
name
)
{
public
AttributeRemoveMessage
(
String
nodeId
,
String
sessionId
,
S
et
<
String
>
names
)
{
super
(
nodeId
,
sessionId
);
this
.
name
=
name
;
this
.
name
s
=
names
;
}
public
S
tring
getName
()
{
return
name
;
public
S
et
<
String
>
getNames
()
{
return
name
s
;
}
}
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java
浏览文件 @
4b023aa3
...
...
@@ -25,6 +25,7 @@ import java.util.HashSet;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.catalina.session.StandardSession
;
...
...
@@ -59,6 +60,8 @@ public class RedissonSession extends StandardSession {
private
final
RedissonSessionManager
.
ReadMode
readMode
;
private
final
UpdateMode
updateMode
;
private
Set
<
String
>
removedAttributes
;
public
RedissonSession
(
RedissonSessionManager
manager
,
RedissonSessionManager
.
ReadMode
readMode
,
UpdateMode
updateMode
)
{
super
(
manager
);
this
.
redissonManager
=
manager
;
...
...
@@ -66,6 +69,10 @@ public class RedissonSession extends StandardSession {
this
.
updateMode
=
updateMode
;
this
.
topic
=
redissonManager
.
getTopic
();
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
=
Collections
.
newSetFromMap
(
new
ConcurrentHashMap
<
String
,
Boolean
>());
}
try
{
Field
attr
=
StandardSession
.
class
.
getDeclaredField
(
"attributes"
);
attrs
=
(
Map
<
String
,
Object
>)
attr
.
get
(
this
);
...
...
@@ -257,6 +264,9 @@ public class RedissonSession extends StandardSession {
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
&&
value
!=
null
)
{
fastPut
(
name
,
value
);
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
.
remove
(
name
);
}
}
public
void
superRemoveAttributeInternal
(
String
name
,
boolean
notify
)
{
...
...
@@ -270,9 +280,12 @@ public class RedissonSession extends StandardSession {
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
)
{
map
.
fastRemove
(
name
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
n
ame
));
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
n
ew
HashSet
<
String
>(
Arrays
.
asList
(
name
))
));
}
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
.
add
(
name
);
}
}
public
void
save
()
{
...
...
@@ -295,9 +308,19 @@ public class RedissonSession extends StandardSession {
}
map
.
putAll
(
newMap
);
map
.
fastRemove
(
removedAttributes
.
toArray
(
new
String
[
removedAttributes
.
size
()]));
if
(
readMode
==
ReadMode
.
MEMORY
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
if
(!
removedAttributes
.
isEmpty
())
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
removedAttributes
));
}
}
}
removedAttributes
.
clear
();
expireSession
();
}
...
...
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
浏览文件 @
4b023aa3
...
...
@@ -239,7 +239,9 @@ public class RedissonSessionManager extends ManagerBase {
RedissonSession
session
=
(
RedissonSession
)
RedissonSessionManager
.
super
.
findSession
(
msg
.
getSessionId
());
if
(
session
!=
null
&&
!
msg
.
getNodeId
().
equals
(
nodeId
))
{
if
(
msg
instanceof
AttributeRemoveMessage
)
{
session
.
superRemoveAttributeInternal
(((
AttributeRemoveMessage
)
msg
).
getName
(),
true
);
for
(
String
name
:
((
AttributeRemoveMessage
)
msg
).
getNames
())
{
session
.
superRemoveAttributeInternal
(
name
,
true
);
}
}
if
(
msg
instanceof
AttributesClearMessage
)
{
...
...
@@ -314,11 +316,11 @@ public class RedissonSessionManager extends ManagerBase {
return
;
}
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
RedissonSession
sess
=
(
RedissonSession
)
super
.
findSession
(
session
.
getId
());
if
(
sess
!=
null
)
{
sess
.
save
();
}
RedissonSession
sess
=
(
RedissonSession
)
super
.
findSession
(
session
.
getId
());
if
(
sess
!=
null
)
{
sess
.
access
();
sess
.
endAccess
();
sess
.
save
();
}
}
...
...
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/UpdateValve.java
浏览文件 @
4b023aa3
...
...
@@ -19,7 +19,6 @@ import java.io.IOException;
import
javax.servlet.ServletException
;
import
org.apache.catalina.Session
;
import
org.apache.catalina.connector.Request
;
import
org.apache.catalina.connector.Response
;
import
org.apache.catalina.valves.ValveBase
;
...
...
@@ -41,19 +40,6 @@ public class UpdateValve extends ValveBase {
@Override
public
void
invoke
(
Request
request
,
Response
response
)
throws
IOException
,
ServletException
{
String
sessionId
=
request
.
getRequestedSessionId
();
Session
session
=
request
.
getContext
().
getManager
().
findSession
(
sessionId
);
if
(
session
!=
null
)
{
if
(!
session
.
isValid
())
{
session
.
expire
();
request
.
getContext
().
getManager
().
remove
(
session
);
}
else
{
manager
.
add
(
session
);
session
.
access
();
session
.
endAccess
();
}
}
try
{
getNext
().
invoke
(
request
,
response
);
}
finally
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录