Return-Path: Delivered-To: apmail-hc-dev-archive@www.apache.org Received: (qmail 10669 invoked from network); 21 Jul 2010 09:38:19 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Jul 2010 09:38:19 -0000 Received: (qmail 38014 invoked by uid 500); 21 Jul 2010 09:38:18 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 37812 invoked by uid 500); 21 Jul 2010 09:38:16 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 37802 invoked by uid 99); 21 Jul 2010 09:38:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Jul 2010 09:38:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Jul 2010 09:38:11 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o6L9bo6T011548 for ; Wed, 21 Jul 2010 09:37:50 GMT Message-ID: <20733358.493771279705070117.JavaMail.jira@thor> Date: Wed, 21 Jul 2010 05:37:50 -0400 (EDT) From: "Oleg Kalnichevski (JIRA)" To: dev@hc.apache.org Subject: [jira] Commented: (HTTPCLIENT-969) BasicCookieStore.getCookies() returns non-threadsafe collection In-Reply-To: <22340124.471211279608169970.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HTTPCLIENT-969?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12890632#action_12890632 ] Oleg Kalnichevski commented on HTTPCLIENT-969: ---------------------------------------------- TreeSet might indeed be a better underlying data structure for this class. I do not see much of a problem with synchronisation on class methods, though. Anyway, we happily accept patches. Oleg > BasicCookieStore.getCookies() returns non-threadsafe collection > --------------------------------------------------------------- > > Key: HTTPCLIENT-969 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-969 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient > Reporter: David Smiley > Priority: Minor > Fix For: 4.0.2, 4.1 Alpha3 > > > BasicCookieStore.getCookies() is a simple method. It's synchronized, and it returns an unmodifiable wrapper around the underlying cookie list. If the caller were to then iterate over it as another thread were to manipulate the cookie list via BasicCookieStore, this would create a thread un-safe situation because both threads aren't doing their reading/writing with the same lock (the reader doesn't even have a lock). > I suggest fixing this by using CopyOnWriteArrayList, or by making a defensive copy in getCookies() > This issue might apply to some of the other basic implementations of some of the interfaces but I haven't checked. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org