Skip to content
Permalink
Browse files
[JENKINS-30662] - Thread safety in UserContext
  • Loading branch information
oleg-nenashev committed Sep 27, 2015
1 parent 77c2370 commit 850219b6ed0a3cd07b47c31cd92521d1fae5b074
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/main/java/com/synopsys/arc/jenkinsci/plugins/dynamic_search/views/UserContextCache.java
@@ -36,22 +36,22 @@
class UserContextCache {
Map<String, UserContext> contextMap = new HashMap<String, UserContext>();

public boolean containsKey(String sessionId) {
public synchronized boolean containsKey(String sessionId) {
return contextMap.containsKey(sessionId);
}

@CheckForNull
public UserContext get(String sessionId) {
public synchronized UserContext get(String sessionId) {
return contextMap.get(sessionId);
}

public void flush(String sessionId) {
public synchronized void flush(String sessionId) {
if (contextMap.containsKey(sessionId)) {
contextMap.remove(sessionId);
}
}

public void put (String sessionId, UserContext context) {
public synchronized void put (String sessionId, UserContext context) {
contextMap.put(getSessionId(), context);
}
}

0 comments on commit 850219b

Please sign in to comment.