commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LANG-204) [lang] org.apache.commons.lang.Entities multithreaded init.
Date Tue, 24 Oct 2006 21:10:17 GMT
    [ http://issues.apache.org/jira/browse/LANG-204?page=comments#action_12444512 ] 
            
Henri Yandell commented on LANG-204:
------------------------------------

I guess this is a classic singleton bit, so our solution needs to be to apply the correct
singleton pattern here. 

> [lang] org.apache.commons.lang.Entities multithreaded init.
> -----------------------------------------------------------
>
>                 Key: LANG-204
>                 URL: http://issues.apache.org/jira/browse/LANG-204
>             Project: Commons Lang
>          Issue Type: Improvement
>    Affects Versions: 2.1
>         Environment: Operating System: other
> Platform: Other
>            Reporter: Gary Gregory
>            Priority: Minor
>             Fix For: 3.0
>
>
> -----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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message