DefaultSessionCache is designed to be extended, by virtue of its protected session map. Subclasses can set their own map instance instead. However the session map is specified as ConcurrentHashMap, when it only needs to be ConcurrentMap. Changed data type to ConcurrentMap to allow for wider options for subclasses, such as those wanted to use Caffeine's asMap() method which returns ConcurrentMap. Although changing to even more relaxed Map would work, that does not provide as much clarity that the map will be used concurrently - therefore used ConcurrentMap instead. Signed-off-by: Padraic Renaghan <padraic@renaghan.com>
This commit is contained in:
parent
17bc566155
commit
96945c7e10
|
@ -14,6 +14,7 @@
|
||||||
package org.eclipse.jetty.server.session;
|
package org.eclipse.jetty.server.session;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
||||||
/**
|
/**
|
||||||
* DefaultSessionCache
|
* DefaultSessionCache
|
||||||
*
|
*
|
||||||
* A session store that keeps its sessions in memory in a hashmap
|
* A session store that keeps its sessions in memory in a concurrent map
|
||||||
*/
|
*/
|
||||||
@ManagedObject
|
@ManagedObject
|
||||||
public class DefaultSessionCache extends AbstractSessionCache
|
public class DefaultSessionCache extends AbstractSessionCache
|
||||||
|
@ -35,9 +36,9 @@ public class DefaultSessionCache extends AbstractSessionCache
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(DefaultSessionCache.class);
|
private static final Logger LOG = LoggerFactory.getLogger(DefaultSessionCache.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cache of sessions in a hashmap
|
* The cache of sessions in a concurrent map
|
||||||
*/
|
*/
|
||||||
protected ConcurrentHashMap<String, Session> _sessions = new ConcurrentHashMap<>();
|
protected ConcurrentMap<String, Session> _sessions = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final CounterStatistic _stats = new CounterStatistic();
|
private final CounterStatistic _stats = new CounterStatistic();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue