On Thu, Aug 6, 2009 at 12:10 PM, sebb<seb...@gmail.com> wrote: > On 06/08/2009, ggreg...@apache.org <ggreg...@apache.org> wrote: >> Author: ggregory >> Date: Thu Aug 6 01:30:08 2009 >> New Revision: 801488 >> >> URL: http://svn.apache.org/viewvc?rev=801488&view=rev >> Log: >> [CODEC-55] make all "business" method implementations of public API thread >> safe. >> >> Modified: >> >> commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java >> >> Modified: >> commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java >> URL: >> http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java?rev=801488&r1=801487&r2=801488&view=diff >> ============================================================================== >> --- >> commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java >> (original) >> +++ >> commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java >> Thu Aug 6 01:30:08 2009 >> @@ -291,7 +291,7 @@ >> * @param charsetName >> * the charset name. >> */ >> - public void setCharsetName(String charsetName) { >> + private void setCharsetName(String charsetName) { >> this.charsetName = charsetName; >> } > > That does not actually help much with thread-safety. > The charsetName field is not final, so is not safely published. > If one thread creates an instance, and passes it to another running > thread, in the absence of any synch. there is no guarantee that the > other thread will see the latest value. > > Either get/set need to be synch, or make the field final.
I fixed this by making the field final. Niall >> >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org