On 19/10/2009, Henri Yandell <flame...@gmail.com> wrote: > On Sun, Oct 18, 2009 at 6:45 PM, sebb <seb...@gmail.com> wrote: > > On 18/10/2009, bay...@apache.org <bay...@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-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org