Fixed - Tomcat Session Manager doesn't remove session attributes in updateMode=AFTER_REQUEST. #1971

pull/2041/head
Nikita Koksharov 6 years ago
parent d75f610233
commit 4b023aa341

@ -15,6 +15,8 @@
*/ */
package org.redisson.tomcat; package org.redisson.tomcat;
import java.util.Set;
/** /**
* *
* @author Nikita Koksharov * @author Nikita Koksharov
@ -22,19 +24,19 @@ package org.redisson.tomcat;
*/ */
public class AttributeRemoveMessage extends AttributeMessage { public class AttributeRemoveMessage extends AttributeMessage {
private String name; private Set<String> names;
public AttributeRemoveMessage() { public AttributeRemoveMessage() {
super(); super();
} }
public AttributeRemoveMessage(String nodeId, String sessionId, String name) { public AttributeRemoveMessage(String nodeId, String sessionId, Set<String> names) {
super(nodeId, sessionId); super(nodeId, sessionId);
this.name = name; this.names = names;
} }
public String getName() { public Set<String> getNames() {
return name; return names;
} }
} }

@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.catalina.session.StandardSession; import org.apache.catalina.session.StandardSession;
@ -59,6 +60,8 @@ public class RedissonSession extends StandardSession {
private final RedissonSessionManager.ReadMode readMode; private final RedissonSessionManager.ReadMode readMode;
private final UpdateMode updateMode; private final UpdateMode updateMode;
private Set<String> removedAttributes;
public RedissonSession(RedissonSessionManager manager, ReadMode readMode, UpdateMode updateMode) { public RedissonSession(RedissonSessionManager manager, ReadMode readMode, UpdateMode updateMode) {
super(manager); super(manager);
this.redissonManager = manager; this.redissonManager = manager;
@ -66,6 +69,10 @@ public class RedissonSession extends StandardSession {
this.updateMode = updateMode; this.updateMode = updateMode;
this.topic = redissonManager.getTopic(); this.topic = redissonManager.getTopic();
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
}
try { try {
Field attr = StandardSession.class.getDeclaredField("attributes"); Field attr = StandardSession.class.getDeclaredField("attributes");
attrs = (Map<String, Object>) attr.get(this); attrs = (Map<String, Object>) attr.get(this);
@ -257,6 +264,9 @@ public class RedissonSession extends StandardSession {
if (updateMode == UpdateMode.DEFAULT && map != null && value != null) { if (updateMode == UpdateMode.DEFAULT && map != null && value != null) {
fastPut(name, value); fastPut(name, value);
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes.remove(name);
}
} }
public void superRemoveAttributeInternal(String name, boolean notify) { public void superRemoveAttributeInternal(String name, boolean notify) {
@ -270,8 +280,11 @@ public class RedissonSession extends StandardSession {
if (updateMode == UpdateMode.DEFAULT && map != null) { if (updateMode == UpdateMode.DEFAULT && map != null) {
map.fastRemove(name); map.fastRemove(name);
if (readMode == ReadMode.MEMORY) { if (readMode == ReadMode.MEMORY) {
topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), name)); topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), new HashSet<String>(Arrays.asList(name))));
}
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes.add(name);
} }
} }
@ -295,9 +308,18 @@ public class RedissonSession extends StandardSession {
} }
map.putAll(newMap); map.putAll(newMap);
map.fastRemove(removedAttributes.toArray(new String[removedAttributes.size()]));
if (readMode == ReadMode.MEMORY) { if (readMode == ReadMode.MEMORY) {
topic.publish(createPutAllMessage(newMap)); topic.publish(createPutAllMessage(newMap));
if (updateMode == UpdateMode.AFTER_REQUEST) {
if (!removedAttributes.isEmpty()) {
topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), removedAttributes));
}
}
} }
removedAttributes.clear();
expireSession(); expireSession();
} }

@ -260,7 +260,9 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
RedissonSession session = (RedissonSession) RedissonSessionManager.super.findSession(msg.getSessionId()); RedissonSession session = (RedissonSession) RedissonSessionManager.super.findSession(msg.getSessionId());
if (session != null && !msg.getNodeId().equals(nodeId)) { if (session != null && !msg.getNodeId().equals(nodeId)) {
if (msg instanceof AttributeRemoveMessage) { if (msg instanceof AttributeRemoveMessage) {
session.superRemoveAttributeInternal(((AttributeRemoveMessage)msg).getName(), true); for (String name : ((AttributeRemoveMessage)msg).getNames()) {
session.superRemoveAttributeInternal(name, true);
}
} }
if (msg instanceof AttributesClearMessage) { if (msg instanceof AttributesClearMessage) {
@ -332,12 +334,12 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
return; return;
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
RedissonSession sess = (RedissonSession) super.findSession(session.getId()); RedissonSession sess = (RedissonSession) super.findSession(session.getId());
if (sess != null) { if (sess != null) {
sess.access();
sess.endAccess();
sess.save(); sess.save();
} }
} }
}
} }

@ -19,7 +19,6 @@ import java.io.IOException;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.apache.catalina.Session;
import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response; import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase; import org.apache.catalina.valves.ValveBase;
@ -41,19 +40,6 @@ public class UpdateValve extends ValveBase {
@Override @Override
public void invoke(Request request, Response response) throws IOException, ServletException { 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 { try {
getNext().invoke(request, response); getNext().invoke(request, response);
} finally { } finally {

@ -15,6 +15,8 @@
*/ */
package org.redisson.tomcat; package org.redisson.tomcat;
import java.util.Set;
/** /**
* *
* @author Nikita Koksharov * @author Nikita Koksharov
@ -22,19 +24,19 @@ package org.redisson.tomcat;
*/ */
public class AttributeRemoveMessage extends AttributeMessage { public class AttributeRemoveMessage extends AttributeMessage {
private String name; private Set<String> names;
public AttributeRemoveMessage() { public AttributeRemoveMessage() {
super(); super();
} }
public AttributeRemoveMessage(String nodeId, String sessionId, String name) { public AttributeRemoveMessage(String nodeId, String sessionId, Set<String> names) {
super(nodeId, sessionId); super(nodeId, sessionId);
this.name = name; this.names = names;
} }
public String getName() { public Set<String> getNames() {
return name; return names;
} }
} }

@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.catalina.session.StandardSession; import org.apache.catalina.session.StandardSession;
@ -59,6 +60,8 @@ public class RedissonSession extends StandardSession {
private final RedissonSessionManager.ReadMode readMode; private final RedissonSessionManager.ReadMode readMode;
private final UpdateMode updateMode; private final UpdateMode updateMode;
private Set<String> removedAttributes;
public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) { public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) {
super(manager); super(manager);
this.redissonManager = manager; this.redissonManager = manager;
@ -66,6 +69,10 @@ public class RedissonSession extends StandardSession {
this.updateMode = updateMode; this.updateMode = updateMode;
this.topic = redissonManager.getTopic(); this.topic = redissonManager.getTopic();
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
}
try { try {
Field attr = StandardSession.class.getDeclaredField("attributes"); Field attr = StandardSession.class.getDeclaredField("attributes");
attrs = (Map<String, Object>) attr.get(this); attrs = (Map<String, Object>) attr.get(this);
@ -257,6 +264,9 @@ public class RedissonSession extends StandardSession {
if (updateMode == UpdateMode.DEFAULT && map != null && value != null) { if (updateMode == UpdateMode.DEFAULT && map != null && value != null) {
fastPut(name, value); fastPut(name, value);
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes.remove(name);
}
} }
public void superRemoveAttributeInternal(String name, boolean notify) { public void superRemoveAttributeInternal(String name, boolean notify) {
@ -270,8 +280,11 @@ public class RedissonSession extends StandardSession {
if (updateMode == UpdateMode.DEFAULT && map != null) { if (updateMode == UpdateMode.DEFAULT && map != null) {
map.fastRemove(name); map.fastRemove(name);
if (readMode == ReadMode.MEMORY) { if (readMode == ReadMode.MEMORY) {
topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), name)); topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), new HashSet<String>(Arrays.asList(name))));
}
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes.add(name);
} }
} }
@ -295,9 +308,18 @@ public class RedissonSession extends StandardSession {
} }
map.putAll(newMap); map.putAll(newMap);
map.fastRemove(removedAttributes.toArray(new String[removedAttributes.size()]));
if (readMode == ReadMode.MEMORY) { if (readMode == ReadMode.MEMORY) {
topic.publish(createPutAllMessage(newMap)); topic.publish(createPutAllMessage(newMap));
if (updateMode == UpdateMode.AFTER_REQUEST) {
if (!removedAttributes.isEmpty()) {
topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), removedAttributes));
}
}
} }
removedAttributes.clear();
expireSession(); expireSession();
} }

@ -240,7 +240,9 @@ public class RedissonSessionManager extends ManagerBase {
RedissonSession session = (RedissonSession) RedissonSessionManager.super.findSession(msg.getSessionId()); RedissonSession session = (RedissonSession) RedissonSessionManager.super.findSession(msg.getSessionId());
if (session != null && !msg.getNodeId().equals(nodeId)) { if (session != null && !msg.getNodeId().equals(nodeId)) {
if (msg instanceof AttributeRemoveMessage) { if (msg instanceof AttributeRemoveMessage) {
session.superRemoveAttributeInternal(((AttributeRemoveMessage)msg).getName(), true); for (String name : ((AttributeRemoveMessage)msg).getNames()) {
session.superRemoveAttributeInternal(name, true);
}
} }
if (msg instanceof AttributesClearMessage) { if (msg instanceof AttributesClearMessage) {
@ -315,12 +317,12 @@ public class RedissonSessionManager extends ManagerBase {
return; return;
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
RedissonSession sess = (RedissonSession) super.findSession(session.getId()); RedissonSession sess = (RedissonSession) super.findSession(session.getId());
if (sess != null) { if (sess != null) {
sess.access();
sess.endAccess();
sess.save(); sess.save();
} }
} }
}
} }

@ -19,7 +19,6 @@ import java.io.IOException;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.apache.catalina.Session;
import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response; import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase; import org.apache.catalina.valves.ValveBase;
@ -41,19 +40,6 @@ public class UpdateValve extends ValveBase {
@Override @Override
public void invoke(Request request, Response response) throws IOException, ServletException { 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 { try {
getNext().invoke(request, response); getNext().invoke(request, response);
} finally { } finally {

@ -15,6 +15,8 @@
*/ */
package org.redisson.tomcat; package org.redisson.tomcat;
import java.util.Set;
/** /**
* *
* @author Nikita Koksharov * @author Nikita Koksharov
@ -22,19 +24,19 @@ package org.redisson.tomcat;
*/ */
public class AttributeRemoveMessage extends AttributeMessage { public class AttributeRemoveMessage extends AttributeMessage {
private String name; private Set<String> names;
public AttributeRemoveMessage() { public AttributeRemoveMessage() {
super(); super();
} }
public AttributeRemoveMessage(String nodeId, String sessionId, String name) { public AttributeRemoveMessage(String nodeId, String sessionId, Set<String> names) {
super(nodeId, sessionId); super(nodeId, sessionId);
this.name = name; this.names = names;
} }
public String getName() { public Set<String> getNames() {
return name; return names;
} }
} }

@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.catalina.session.StandardSession; import org.apache.catalina.session.StandardSession;
@ -59,6 +60,8 @@ public class RedissonSession extends StandardSession {
private final RedissonSessionManager.ReadMode readMode; private final RedissonSessionManager.ReadMode readMode;
private final UpdateMode updateMode; private final UpdateMode updateMode;
private Set<String> removedAttributes;
public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) { public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) {
super(manager); super(manager);
this.redissonManager = manager; this.redissonManager = manager;
@ -66,6 +69,10 @@ public class RedissonSession extends StandardSession {
this.updateMode = updateMode; this.updateMode = updateMode;
this.topic = redissonManager.getTopic(); this.topic = redissonManager.getTopic();
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
}
try { try {
Field attr = StandardSession.class.getDeclaredField("attributes"); Field attr = StandardSession.class.getDeclaredField("attributes");
attrs = (Map<String, Object>) attr.get(this); attrs = (Map<String, Object>) attr.get(this);
@ -257,6 +264,9 @@ public class RedissonSession extends StandardSession {
if (updateMode == UpdateMode.DEFAULT && map != null && value != null) { if (updateMode == UpdateMode.DEFAULT && map != null && value != null) {
fastPut(name, value); fastPut(name, value);
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes.remove(name);
}
} }
public void superRemoveAttributeInternal(String name, boolean notify) { public void superRemoveAttributeInternal(String name, boolean notify) {
@ -270,8 +280,11 @@ public class RedissonSession extends StandardSession {
if (updateMode == UpdateMode.DEFAULT && map != null) { if (updateMode == UpdateMode.DEFAULT && map != null) {
map.fastRemove(name); map.fastRemove(name);
if (readMode == ReadMode.MEMORY) { if (readMode == ReadMode.MEMORY) {
topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), name)); topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), new HashSet<String>(Arrays.asList(name))));
}
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes.add(name);
} }
} }
@ -295,9 +308,18 @@ public class RedissonSession extends StandardSession {
} }
map.putAll(newMap); map.putAll(newMap);
map.fastRemove(removedAttributes.toArray(new String[removedAttributes.size()]));
if (readMode == ReadMode.MEMORY) { if (readMode == ReadMode.MEMORY) {
topic.publish(createPutAllMessage(newMap)); topic.publish(createPutAllMessage(newMap));
if (updateMode == UpdateMode.AFTER_REQUEST) {
if (!removedAttributes.isEmpty()) {
topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), removedAttributes));
}
}
} }
removedAttributes.clear();
expireSession(); expireSession();
} }

@ -239,7 +239,9 @@ public class RedissonSessionManager extends ManagerBase {
RedissonSession session = (RedissonSession) RedissonSessionManager.super.findSession(msg.getSessionId()); RedissonSession session = (RedissonSession) RedissonSessionManager.super.findSession(msg.getSessionId());
if (session != null && !msg.getNodeId().equals(nodeId)) { if (session != null && !msg.getNodeId().equals(nodeId)) {
if (msg instanceof AttributeRemoveMessage) { if (msg instanceof AttributeRemoveMessage) {
session.superRemoveAttributeInternal(((AttributeRemoveMessage)msg).getName(), true); for (String name : ((AttributeRemoveMessage)msg).getNames()) {
session.superRemoveAttributeInternal(name, true);
}
} }
if (msg instanceof AttributesClearMessage) { if (msg instanceof AttributesClearMessage) {
@ -314,12 +316,12 @@ public class RedissonSessionManager extends ManagerBase {
return; return;
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
RedissonSession sess = (RedissonSession) super.findSession(session.getId()); RedissonSession sess = (RedissonSession) super.findSession(session.getId());
if (sess != null) { if (sess != null) {
sess.access();
sess.endAccess();
sess.save(); sess.save();
} }
} }
}
} }

@ -19,7 +19,6 @@ import java.io.IOException;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.apache.catalina.Session;
import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response; import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase; import org.apache.catalina.valves.ValveBase;
@ -41,19 +40,6 @@ public class UpdateValve extends ValveBase {
@Override @Override
public void invoke(Request request, Response response) throws IOException, ServletException { 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 { try {
getNext().invoke(request, response); getNext().invoke(request, response);
} finally { } finally {

@ -15,6 +15,8 @@
*/ */
package org.redisson.tomcat; package org.redisson.tomcat;
import java.util.Set;
/** /**
* *
* @author Nikita Koksharov * @author Nikita Koksharov
@ -22,19 +24,19 @@ package org.redisson.tomcat;
*/ */
public class AttributeRemoveMessage extends AttributeMessage { public class AttributeRemoveMessage extends AttributeMessage {
private String name; private Set<String> names;
public AttributeRemoveMessage() { public AttributeRemoveMessage() {
super(); super();
} }
public AttributeRemoveMessage(String nodeId, String sessionId, String name) { public AttributeRemoveMessage(String nodeId, String sessionId, Set<String> names) {
super(nodeId, sessionId); super(nodeId, sessionId);
this.name = name; this.names = names;
} }
public String getName() { public Set<String> getNames() {
return name; return names;
} }
} }

@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.catalina.session.StandardSession; import org.apache.catalina.session.StandardSession;
@ -59,6 +60,8 @@ public class RedissonSession extends StandardSession {
private final RedissonSessionManager.ReadMode readMode; private final RedissonSessionManager.ReadMode readMode;
private final UpdateMode updateMode; private final UpdateMode updateMode;
private Set<String> removedAttributes;
public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) { public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) {
super(manager); super(manager);
this.redissonManager = manager; this.redissonManager = manager;
@ -66,6 +69,10 @@ public class RedissonSession extends StandardSession {
this.updateMode = updateMode; this.updateMode = updateMode;
this.topic = redissonManager.getTopic(); this.topic = redissonManager.getTopic();
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
}
try { try {
Field attr = StandardSession.class.getDeclaredField("attributes"); Field attr = StandardSession.class.getDeclaredField("attributes");
attrs = (Map<String, Object>) attr.get(this); attrs = (Map<String, Object>) attr.get(this);
@ -257,6 +264,9 @@ public class RedissonSession extends StandardSession {
if (updateMode == UpdateMode.DEFAULT && map != null && value != null) { if (updateMode == UpdateMode.DEFAULT && map != null && value != null) {
fastPut(name, value); fastPut(name, value);
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes.remove(name);
}
} }
public void superRemoveAttributeInternal(String name, boolean notify) { public void superRemoveAttributeInternal(String name, boolean notify) {
@ -270,8 +280,11 @@ public class RedissonSession extends StandardSession {
if (updateMode == UpdateMode.DEFAULT && map != null) { if (updateMode == UpdateMode.DEFAULT && map != null) {
map.fastRemove(name); map.fastRemove(name);
if (readMode == ReadMode.MEMORY) { if (readMode == ReadMode.MEMORY) {
topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), name)); topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), new HashSet<String>(Arrays.asList(name))));
}
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
removedAttributes.add(name);
} }
} }
@ -295,9 +308,19 @@ public class RedissonSession extends StandardSession {
} }
map.putAll(newMap); map.putAll(newMap);
map.fastRemove(removedAttributes.toArray(new String[removedAttributes.size()]));
if (readMode == ReadMode.MEMORY) { if (readMode == ReadMode.MEMORY) {
topic.publish(createPutAllMessage(newMap)); topic.publish(createPutAllMessage(newMap));
if (updateMode == UpdateMode.AFTER_REQUEST) {
if (!removedAttributes.isEmpty()) {
topic.publish(new AttributeRemoveMessage(redissonManager.getNodeId(), getId(), removedAttributes));
}
} }
}
removedAttributes.clear();
expireSession(); expireSession();
} }

@ -239,7 +239,9 @@ public class RedissonSessionManager extends ManagerBase {
RedissonSession session = (RedissonSession) RedissonSessionManager.super.findSession(msg.getSessionId()); RedissonSession session = (RedissonSession) RedissonSessionManager.super.findSession(msg.getSessionId());
if (session != null && !msg.getNodeId().equals(nodeId)) { if (session != null && !msg.getNodeId().equals(nodeId)) {
if (msg instanceof AttributeRemoveMessage) { if (msg instanceof AttributeRemoveMessage) {
session.superRemoveAttributeInternal(((AttributeRemoveMessage)msg).getName(), true); for (String name : ((AttributeRemoveMessage)msg).getNames()) {
session.superRemoveAttributeInternal(name, true);
}
} }
if (msg instanceof AttributesClearMessage) { if (msg instanceof AttributesClearMessage) {
@ -314,12 +316,12 @@ public class RedissonSessionManager extends ManagerBase {
return; return;
} }
if (updateMode == UpdateMode.AFTER_REQUEST) {
RedissonSession sess = (RedissonSession) super.findSession(session.getId()); RedissonSession sess = (RedissonSession) super.findSession(session.getId());
if (sess != null) { if (sess != null) {
sess.access();
sess.endAccess();
sess.save(); sess.save();
} }
} }
}
} }

@ -19,7 +19,6 @@ import java.io.IOException;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.apache.catalina.Session;
import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response; import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase; import org.apache.catalina.valves.ValveBase;
@ -41,19 +40,6 @@ public class UpdateValve extends ValveBase {
@Override @Override
public void invoke(Request request, Response response) throws IOException, ServletException { 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 { try {
getNext().invoke(request, response); getNext().invoke(request, response);
} finally { } finally {

Loading…
Cancel
Save