提交 d8ae21e5 编写于 作者: N Nikita Koksharov

Fixed - ClassNotFoundException is thrown by Tomcat Session Manager in readMode = MEMORY #1959

上级 d5ee9a72
......@@ -51,6 +51,7 @@ public class RedissonSession extends StandardSession {
public static final Set<String> ATTRS = new HashSet<String>(Arrays.asList(IS_NEW_ATTR, IS_VALID_ATTR,
THIS_ACCESSED_TIME_ATTR, MAX_INACTIVE_INTERVAL_ATTR, LAST_ACCESSED_TIME_ATTR, CREATION_TIME_ATTR));
private boolean loaded;
private final RedissonSessionManager redissonManager;
private final Map<String, Object> attrs;
private RMap<String, Object> map;
......@@ -87,6 +88,17 @@ public class RedissonSession extends StandardSession {
}
return map.get(name);
} else {
if (!loaded) {
synchronized (this) {
if (!loaded) {
Map<String, Object> storedAttrs = map.readAllMap();
load(storedAttrs);
loaded = true;
}
}
}
}
return super.getAttribute(name);
......
......@@ -170,13 +170,9 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
if (id != null) {
Map<String, Object> attrs = new HashMap<String, Object>();
try {
if (readMode == ReadMode.MEMORY) {
attrs = getMap(id).readAllMap();
} else {
attrs = getMap(id).getAll(RedissonSession.ATTRS);
}
attrs = getMap(id).getAll(RedissonSession.ATTRS);
} catch (Exception e) {
throw new IOException(e);
log.error("Can't read session object by id: " + id, e);
}
RedissonSession session = (RedissonSession) createEmptySession();
......
......@@ -51,6 +51,7 @@ public class RedissonSession extends StandardSession {
public static final Set<String> ATTRS = new HashSet<String>(Arrays.asList(IS_NEW_ATTR, IS_VALID_ATTR,
THIS_ACCESSED_TIME_ATTR, MAX_INACTIVE_INTERVAL_ATTR, LAST_ACCESSED_TIME_ATTR, CREATION_TIME_ATTR));
private boolean loaded;
private final RedissonSessionManager redissonManager;
private final Map<String, Object> attrs;
private RMap<String, Object> map;
......@@ -87,6 +88,17 @@ public class RedissonSession extends StandardSession {
}
return map.get(name);
} else {
if (!loaded) {
synchronized (this) {
if (!loaded) {
Map<String, Object> storedAttrs = map.readAllMap();
load(storedAttrs);
loaded = true;
}
}
}
}
return super.getAttribute(name);
......
......@@ -148,13 +148,9 @@ public class RedissonSessionManager extends ManagerBase {
if (id != null) {
Map<String, Object> attrs = new HashMap<String, Object>();
try {
if (readMode == ReadMode.MEMORY) {
attrs = getMap(id).readAllMap();
} else {
attrs = getMap(id).getAll(RedissonSession.ATTRS);
}
attrs = getMap(id).getAll(RedissonSession.ATTRS);
} catch (Exception e) {
throw new IOException(e);
log.error("Can't read session object by id: " + id, e);
}
RedissonSession session = (RedissonSession) createEmptySession();
......
......@@ -51,6 +51,7 @@ public class RedissonSession extends StandardSession {
public static final Set<String> ATTRS = new HashSet<String>(Arrays.asList(IS_NEW_ATTR, IS_VALID_ATTR,
THIS_ACCESSED_TIME_ATTR, MAX_INACTIVE_INTERVAL_ATTR, LAST_ACCESSED_TIME_ATTR, CREATION_TIME_ATTR));
private boolean loaded;
private final RedissonSessionManager redissonManager;
private final Map<String, Object> attrs;
private RMap<String, Object> map;
......@@ -87,6 +88,17 @@ public class RedissonSession extends StandardSession {
}
return map.get(name);
} else {
if (!loaded) {
synchronized (this) {
if (!loaded) {
Map<String, Object> storedAttrs = map.readAllMap();
load(storedAttrs);
loaded = true;
}
}
}
}
return super.getAttribute(name);
......
......@@ -147,13 +147,9 @@ public class RedissonSessionManager extends ManagerBase {
if (id != null) {
Map<String, Object> attrs = new HashMap<String, Object>();
try {
if (readMode == ReadMode.MEMORY) {
attrs = getMap(id).readAllMap();
} else {
attrs = getMap(id).getAll(RedissonSession.ATTRS);
}
attrs = getMap(id).getAll(RedissonSession.ATTRS);
} catch (Exception e) {
throw new IOException(e);
log.error("Can't read session object by id: " + id, e);
}
RedissonSession session = (RedissonSession) createEmptySession();
......
......@@ -51,6 +51,7 @@ public class RedissonSession extends StandardSession {
public static final Set<String> ATTRS = new HashSet<String>(Arrays.asList(IS_NEW_ATTR, IS_VALID_ATTR,
THIS_ACCESSED_TIME_ATTR, MAX_INACTIVE_INTERVAL_ATTR, LAST_ACCESSED_TIME_ATTR, CREATION_TIME_ATTR));
private boolean loaded;
private final RedissonSessionManager redissonManager;
private final Map<String, Object> attrs;
private RMap<String, Object> map;
......@@ -87,6 +88,17 @@ public class RedissonSession extends StandardSession {
}
return map.get(name);
} else {
if (!loaded) {
synchronized (this) {
if (!loaded) {
Map<String, Object> storedAttrs = map.readAllMap();
load(storedAttrs);
loaded = true;
}
}
}
}
return super.getAttribute(name);
......
......@@ -147,13 +147,9 @@ public class RedissonSessionManager extends ManagerBase {
if (id != null) {
Map<String, Object> attrs = new HashMap<String, Object>();
try {
if (readMode == ReadMode.MEMORY) {
attrs = getMap(id).readAllMap();
} else {
attrs = getMap(id).getAll(RedissonSession.ATTRS);
}
attrs = getMap(id).getAll(RedissonSession.ATTRS);
} catch (Exception e) {
throw new IOException(e);
log.error("Can't read session object by id: " + id, e);
}
RedissonSession session = (RedissonSession) createEmptySession();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册