Skip to content

Commit f95b8be

Browse files
committed
ROL-2101 Thread unsafe use of HashMap for cached mappings exist
1 parent 11f322d commit f95b8be

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAUserManagerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.roller.weblogger.business.UserManager;
2828

2929
import java.util.ArrayList;
30+
import java.util.Collections;
3031
import java.util.Date;
3132
import java.util.HashMap;
3233
import java.util.List;
@@ -49,7 +50,7 @@ public class JPAUserManagerImpl implements UserManager {
4950
private final JPAPersistenceStrategy strategy;
5051

5152
// cached mapping of userNames -> userIds
52-
private Map<String, String> userNameToIdMap = new HashMap<String, String>();
53+
private Map<String, String> userNameToIdMap = Collections.synchronizedMap(new HashMap<String, String>());
5354

5455

5556
@com.google.inject.Inject

app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class JPAWeblogEntryManagerImpl implements WeblogEntryManager {
6868
private final JPAPersistenceStrategy strategy;
6969

7070
// cached mapping of entryAnchors -> entryIds
71-
private Map<String, String> entryAnchorToIdMap = new HashMap<String, String>();
71+
private Map<String, String> entryAnchorToIdMap = Collections.synchronizedMap(new HashMap<String, String>());
7272

7373
private static final Comparator<TagStat> TAG_STAT_NAME_COMPARATOR = new TagStatComparator();
7474

0 commit comments

Comments
 (0)