On 3 June 2017 at 08:40, Gilles <gil...@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.

> Regards,
> Gilles
>
>
>
> On Sat,  3 Jun 2017 06:03:05 +0000 (UTC), djo...@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 <dun...@wortharead.com>
>> Authored: Sat Jun 3 07:03:18 2017 +0100
>> Committer: duncan <dun...@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-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>

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

Reply via email to