commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Duncan Jones <dun...@wortharead.com>
Subject Re: [text] Correct RandomStringGenerator description of thread safety/immutability
Date Sun, 04 Jun 2017 07:35:49 GMT

> On 3 Jun 2017, at 09:55, sebb <sebbaz@gmail.com> wrote:
> 
> On 3 June 2017 at 08:40, Gilles <gilles@harfang.homelinux.org> wrote:
>> Hi Duncan.
>> 
>> Can we really say that "RandomStringBuilder instances
>> are _immutable_ [...] if using the default random number
>> generator"?
>> Calling "nextInt" on the instance returned by
>>  ThreadLocalRandom.current()
>> does change some internal state...
> 
> Agreed, there must be some internal state for 'next' to have any meaning.
> 
>> [IOW, unless I'm missing something, I think that "immutable"
>> should not be mentioned at all in this Javadoc.]
> 
> +1
> 
> What's important here is the thread-safety aspect.

Thanks for the feedback guys, I’ve pushed an update to remove the offending docs.

> 
>> Regards,
>> Gilles
>> 
>> 
>> 
>> On Sat,  3 Jun 2017 06:03:05 +0000 (UTC), djones@apache.org wrote:
>>> 
>>> Repository: commons-text
>>> Updated Branches:
>>>  refs/heads/master ebb0cbe8c -> d04b0f6ff
>>> 
>>> 
>>> Correct RandomStringGenerator description of thread safety/immutability
>>> 
>>> The thread safety and immutability of RandomStringGenerator is dependent
>>> upon the external source of randomness, if set. Updated the Javadocs to
>>> reflect this.
>>> 
>>> Fixes: TEXT-84
>>> 
>>> Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
>>> Commit:
>>> http://git-wip-us.apache.org/repos/asf/commons-text/commit/d04b0f6f
>>> Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/d04b0f6f
>>> Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/d04b0f6f
>>> 
>>> Branch: refs/heads/master
>>> Commit: d04b0f6ff469c1674d251c542028697db3ca48af
>>> Parents: ebb0cbe
>>> Author: duncan <duncan@wortharead.com>
>>> Authored: Sat Jun 3 07:03:18 2017 +0100
>>> Committer: duncan <duncan@wortharead.com>
>>> Committed: Sat Jun 3 07:03:18 2017 +0100
>>> 
>>> 
>>> ----------------------------------------------------------------------
>>> src/changes/changes.xml                                         | 1 +
>>> .../java/org/apache/commons/text/RandomStringGenerator.java     | 5 ++++-
>>> 2 files changed, 5 insertions(+), 1 deletion(-)
>>> 
>>> ----------------------------------------------------------------------
>>> 
>>> 
>>> 
>>> 
>>> http://git-wip-us.apache.org/repos/asf/commons-text/blob/d04b0f6f/src/changes/changes.xml
>>> 
>>> ----------------------------------------------------------------------
>>> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
>>> index d3cc0df..7b65a6d 100644
>>> --- a/src/changes/changes.xml
>>> +++ b/src/changes/changes.xml
>>> @@ -46,6 +46,7 @@ The <action> type attribute can be
>>> add,update,fix,remove.
>>>   <body>
>>> 
>>>   <release version="1.2" date="tbd" description="tbd">
>>> +    <action issue="TEXT-84" type="update"
>>> dev="djones">RandomStringGenerator claims to be immutable, but
>>> isn't</action>
>>>   </release>
>>> 
>>>   <release version="1.1" date="2017-05-23" description="Release 1.1">
>>> 
>>> 
>>> 
>>> http://git-wip-us.apache.org/repos/asf/commons-text/blob/d04b0f6f/src/main/java/org/apache/commons/text/RandomStringGenerator.java
>>> 
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
>>> b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
>>> index 6aa6806..58ebfb8 100644
>>> --- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
>>> +++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
>>> @@ -46,7 +46,10 @@ import org.apache.commons.lang3.Validate;
>>>  * String randomLetters = generator.generate(20);
>>>  * </pre>
>>>  * <p>
>>> - * {@code RandomStringBuilder} instances are immutable and thread-safe.
>>> + * {@code RandomStringBuilder} instances are immutable and
>>> thread-safe if using the
>>> + * default random number generator (RNG). If a custom RNG is set by
>>> calling the method
>>> + * {@link Builder#usingRandom(TextRandomProvider)
>>> Builder.usingRandom(TextRandomProvider)}, thread-safety
>>> + * and immutability must be ensured externally.
>>>  * </p>
>>>  * @since 1.1
>>>  */
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org


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


Mime
View raw message