commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r826514 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java test/org/apache/commons/lang/text/translate/UnicodeUnescaperTest.java
Date Tue, 20 Oct 2009 22:09:40 GMT
On 19/10/2009, Henri Yandell <flamefew@gmail.com> wrote:
> On Sun, Oct 18, 2009 at 6:45 PM, sebb <sebbaz@gmail.com> wrote:
>  > On 18/10/2009, bayard@apache.org <bayard@apache.org> wrote:
>  >> Author: bayard
>  >>  Date: Sun Oct 18 20:14:30 2009
>  >>  New Revision: 826514
>  >>
>  >>  URL: http://svn.apache.org/viewvc?rev=826514&view=rev
>  >>  Log:
>  >>  Sebb pointed out that the implementation for LANG-507 was not thread safe.
Rewriting to pass parameters in to the constructor, but doing so in an experimental way -
comments very much desired on whether this makes for a nice API or not
>  >>
>  >>  Modified:
>  >>     commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java
>  >>     commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/translate/UnicodeUnescaperTest.java
>  >>
>  >>  Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java
>  >>  URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java?rev=826514&r1=826513&r2=826514&view=diff
>  >>  ==============================================================================
>  >>  --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java
(original)
>  >>  +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java
Sun Oct 18 20:14:30 2009
>  >>  @@ -19,6 +19,9 @@
>  >>   import java.io.IOException;
>  >>   import java.io.Writer;
>  >>
>  >>  +import java.util.EnumSet;
>  >>  +import java.util.Arrays;
>  >>  +
>  >>   /**
>  >>   * Translates escaped unicode values of the form \\u+\d\d\d\d back to
>  >>   * unicode.
>  >>  @@ -26,13 +29,18 @@
>  >>   */
>  >>   public class UnicodeUnescaper extends CharSequenceTranslator {
>  >>
>  >>  -    private boolean escapingPlus = false;
>  >>  +    public static enum PARAM { escapePlus };
>  >>  +
>  >>  +    private EnumSet<PARAM> params;
>  >
>
> > This is not final, so its value is not necessarily published to other
>  > threads - i.e. the class is still not thread-safe.
>
>  I guess no reason not to use private final - though EnumSet itself
>  isn't synchronized and I don't see how there is a current thread safe
>  problem (I'm not aware of any way a constructor can be called twice on
>  the same object :) , and the only method call used is contains() which
>  I'll naively assume is thread safe as it would seem to be read-only.

The constructor writes to the EnumSet; if the field is not final then
it might not be published to all other threads.

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

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


Mime
View raw message