You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2009/08/06 03:30:08 UTC

svn commit: r801488 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java

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;
     }
 



Re: svn commit: r801488 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java

Posted by Niall Pemberton <ni...@gmail.com>.
On Thu, Aug 6, 2009 at 12:10 PM, sebb<se...@gmail.com> wrote:
> On 06/08/2009, ggregory@apache.org <gg...@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


Re: svn commit: r801488 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java

Posted by sebb <se...@gmail.com>.
On 06/08/2009, ggregory@apache.org <gg...@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