From issues-return-11720-apmail-commons-issues-archive=commons.apache.org@commons.apache.org Wed Feb 03 01:29:40 2010 Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 72585 invoked from network); 3 Feb 2010 01:29:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Feb 2010 01:29:40 -0000 Received: (qmail 73095 invoked by uid 500); 3 Feb 2010 01:29:40 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 72976 invoked by uid 500); 3 Feb 2010 01:29:39 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 72966 invoked by uid 99); 3 Feb 2010 01:29:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2010 01:29:39 +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.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2010 01:29:38 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id B8E75234C48C for ; Tue, 2 Feb 2010 17:29:18 -0800 (PST) Message-ID: <1983081872.42091265160558756.JavaMail.jira@brutus.apache.org> Date: Wed, 3 Feb 2010 01:29:18 +0000 (UTC) From: "Sebb (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (LANG-204) [lang] org.apache.commons.lang.Entities multithreaded init. 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/LANG-204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12828878#action_12828878 ] Sebb commented on LANG-204: --------------------------- The code is still not thread-safe, as the various nested classes are not thread-safe. However, provided that the XML and other static Entities are not updated externally it seems the static methods ought to be thread-safe. The only issue is whether the data items are published correctly to all threads. I thought that was guaranteed for static fields, but perhaps that was not the case before Java 5. In which case it might be worth using temporary variables to populate the Entities in the static blocks, and assign the static field at the end. It's a pity that the static Entries are not immutable once created. Perhaps they could be wrapped? > [lang] org.apache.commons.lang.Entities multithreaded init. > ----------------------------------------------------------- > > Key: LANG-204 > URL: https://issues.apache.org/jira/browse/LANG-204 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* > Affects Versions: 2.1 > Environment: Operating System: other > Platform: Other > Reporter: Gary Gregory > Priority: Minor > Fix For: 2.x > > > -----Original Message----- > From: Gaulin, David: #CIPO - OPIC [mailto:Gaulin.David@ic.gc.ca] > Sent: Wednesday, April 26, 2006 5:09 AM > To: commons-dev@jakarta.apache.org > Subject: [lang] org.apache.commons.lang.Entities > Hello, > Not sure if it is the right mailling list but here we go anyway. > I am currently using the Entities.java class (well I am using the > StringEscapeUtils.java which uses that class). Works really good, saved me a > lot of time. My thanks to the people who wrote it. > I have encountered a little problems with it taught. Nothing major but I just > taugth I would share since it migth be of interest to you. > I have an heavily multithreaded process that runs on a really under powered > server. All those threads access the StringEscapeUtils.escapeXml() methods > pretty much at the same time. What happens is that by the time the Second or > Third Thread calls the StringEscapeUtils.escapeXml() the static initialization > in the Entities.java class has not completed yet. That block in particular. > static { > XML = new Entities(); > XML.addEntities(BASIC_ARRAY); > XML.addEntities(APOS_ARRAY); > } > I don't get a NullPointer so it seems that XML = new Entities() is actually > being executed before the other Thread starts but the > XML.addEntities(BASIC_ARRAY) on the other hand is not executed before the other > thread starts. So when the second or third thread calls the > StringEscapeUtils.escapeXml() it doesn't escape the BASIC_ARRAY or APOS_ARRAY > entities. To fix it, in my code, I just make sure to call > StringEscapeUtils.escapeXml() before I start any threads and it solve the > problems but if anyone is ever to re-work the class this might be something to > look at. > Just to share. > Thank > David -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.