Skip to content

Commit 8882874

Browse files
committed
Minor comment updates, add release notes
1 parent 30e6de5 commit 8882874

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

release-notes/CREDITS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,7 @@ Daniel Albuquerque (worldtiki@github)
151151
Alexander Ilinykh (divinenickname@github)
152152
* Contributed improvements to README.md, pom.xml (OSGi inclusion)
153153
[5.1.1]
154+
155+
Chad Parry (chadparry@github)
156+
* Contributed #124: TimeBasedEpochGenerator should prevent overflow
157+
[5.3.0]

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Releases
66

77
5.2.0 (not yet released)
88

9+
#124: TimeBasedEpochGenerator should prevent overflow
10+
(Chad P)
911
- Update to `oss-parent` v69
1012

1113
5.1.1 (26-Sep-2025)

src/main/java/com/fasterxml/uuid/impl/TimeBasedEpochGenerator.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public class TimeBasedEpochGenerator extends NoArgGenerator
3434
*/
3535

3636
/**
37-
* Random number generator that fills a byte array with entropy
37+
* Source for random numbers used to fill a byte array with entropy.
38+
*
39+
* @since 5.3 (replaced earlier {@code java.util.Random _random})
3840
*/
3941
protected final Consumer<byte[]> _randomNextBytes;
4042

@@ -77,7 +79,16 @@ public TimeBasedEpochGenerator(Random rnd, UUIDClock clock)
7779
this((rnd == null ? LazyRandom.sharedSecureRandom() : rnd)::nextBytes, clock);
7880
}
7981

80-
TimeBasedEpochGenerator(Consumer<byte[]> randomNextBytes, UUIDClock clock)
82+
/**
83+
*
84+
* @param randomNextBytes Source for random numbers to use for generating UUIDs.
85+
* Note that it is strongly recommend to use a <b>good</b> (pseudo) random number source;
86+
* for example, JDK's {@code SecureRandom::nextBytes}.
87+
* @param clock clock Object used for accessing current time to use for generation
88+
*
89+
* @since 5.3
90+
*/
91+
protected TimeBasedEpochGenerator(Consumer<byte[]> randomNextBytes, UUIDClock clock)
8192
{
8293
_randomNextBytes = randomNextBytes;
8394
_clock = clock;

src/test/java/com/fasterxml/uuid/impl/TimeBasedEpochGeneratorTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package com.fasterxml.uuid.impl;
22

3-
import com.fasterxml.uuid.UUIDClock;
4-
import junit.framework.TestCase;
5-
63
import java.math.BigInteger;
74
import java.util.Arrays;
85
import java.util.UUID;
96
import java.util.function.Consumer;
107

11-
public class TimeBasedEpochGeneratorTest extends TestCase {
8+
import com.fasterxml.uuid.UUIDClock;
9+
import junit.framework.TestCase;
1210

11+
/**
12+
* @since 5.3
13+
*/
14+
public class TimeBasedEpochGeneratorTest extends TestCase
15+
{
1316
public void testFormat() {
1417
BigInteger minEntropy = BigInteger.ZERO;
1518
long minTimestamp = 0;

0 commit comments

Comments
 (0)