Return-Path: X-Original-To: apmail-roller-commits-archive@www.apache.org Delivered-To: apmail-roller-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 12B9818CC2 for ; Mon, 11 Jan 2016 05:31:40 +0000 (UTC) Received: (qmail 93732 invoked by uid 500); 11 Jan 2016 05:31:40 -0000 Delivered-To: apmail-roller-commits-archive@roller.apache.org Received: (qmail 93697 invoked by uid 500); 11 Jan 2016 05:31:40 -0000 Mailing-List: contact commits-help@roller.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@roller.apache.org Delivered-To: mailing list commits@roller.apache.org Received: (qmail 93688 invoked by uid 99); 11 Jan 2016 05:31:39 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jan 2016 05:31:39 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id C36AA2C14F7 for ; Mon, 11 Jan 2016 05:31:39 +0000 (UTC) Date: Mon, 11 Jan 2016 05:31:39 +0000 (UTC) From: "Kohei Nozaki (JIRA)" To: commits@roller.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (ROL-2101) Thread unsafe use of HashMap for cached mappings exist MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/ROL-2101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15091461#comment-15091461 ] Kohei Nozaki commented on ROL-2101: ----------------------------------- OK, I understand that the guard {{if(this.entryAnchorToIdMap.containsKey(mappingKey))}} prevents invocation of database lookup... > Thread unsafe use of HashMap for cached mappings exist > ------------------------------------------------------ > > Key: ROL-2101 > URL: https://issues.apache.org/jira/browse/ROL-2101 > Project: Apache Roller > Issue Type: Bug > Components: Data Model & JPA Backend > Affects Versions: 5.1.2 > Reporter: Kohei Nozaki > Assignee: Roller Unassigned > Priority: Minor > Attachments: ROL-2101.patch > > > There are two singleton classes that have a instance field type of {{HashMap}} for cache. > In {{JPAUserManagerImpl}}: > {noformat} > // cached mapping of userNames -> userIds > private Map userNameToIdMap = new HashMap(); > {noformat} > In {{JPAWeblogEntryManagerImpl}}: > {noformat} > // cached mapping of entryAnchors -> entryIds > private Map entryAnchorToIdMap = new HashMap(); > {noformat} > {{HashMap}} s should not be used as the above because it's not thread safe. -- This message was sent by Atlassian JIRA (v6.3.4#6332)