commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niall Pemberton <niall.pember...@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 13:17:05 GMT
On Thu, Aug 6, 2009 at 12:10 PM, sebb<sebbaz@gmail.com> wrote:
> 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.

I fixed this by making the field final.

Niall

>>
>>
>>

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


Mime
View raw message