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: r801488 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java
Date Thu, 06 Aug 2009 11:10:26 GMT
On 06/08/2009, ggregory@apache.org <ggregory@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.

>
>
>

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


Mime
View raw message