This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit f3de6a4633976753c931fb008e7de704581a49fd Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu Aug 8 07:24:43 2024 -0400 Deprecate static RandomUtils.next*() methods in favor or .secure() and .insecure() versions --- src/changes/changes.xml | 2 ++ .../java/org/apache/commons/lang3/RandomUtils.java | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 01e7a86d8..862e4225b 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,8 @@ The <action> type attribute can be add,update,fix,remove. </properties> <body> <release version="3.16.1" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required."> + <!-- FIX --> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate static RandomUtils.next*() methods in favor or .secure() and .insecure() versions.</action> <!-- ADD --> <action type="add" dev="ggregory" due-to="Gary Gregory">Make RandomUtils.insecure() public.</action> <!-- UPDATE --> diff --git a/src/main/java/org/apache/commons/lang3/RandomUtils.java b/src/main/java/org/apache/commons/lang3/RandomUtils.java index 96ae715ed..c0ef5f246 100644 --- a/src/main/java/org/apache/commons/lang3/RandomUtils.java +++ b/src/main/java/org/apache/commons/lang3/RandomUtils.java @@ -92,7 +92,9 @@ public class RandomUtils { * * @return the random boolean * @since 3.5 + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated public static boolean nextBoolean() { return secure().randomBoolean(); } @@ -103,7 +105,9 @@ public class RandomUtils { * @param count the size of the returned array * @return the random byte array * @throws IllegalArgumentException if {@code count} is negative + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated public static byte[] nextBytes(final int count) { return secure().randomBytes(count); } @@ -114,7 +118,9 @@ public class RandomUtils { * @return the random double * @see #nextDouble(double, double) * @since 3.5 + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated public static double nextDouble() { return secure().randomDouble(); } @@ -127,7 +133,9 @@ public class RandomUtils { * @throws IllegalArgumentException if {@code startInclusive > endExclusive} or if {@code startInclusive} is * negative * @return the random double + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated public static double nextDouble(final double startInclusive, final double endExclusive) { return secure().randomDouble(startInclusive, endExclusive); } @@ -138,7 +146,9 @@ public class RandomUtils { * @return the random float * @see #nextFloat(float, float) * @since 3.5 + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated public static float nextFloat() { return secure().randomFloat(); } @@ -151,7 +161,9 @@ public class RandomUtils { * @throws IllegalArgumentException if {@code startInclusive > endExclusive} or if {@code startInclusive} is * negative * @return the random float + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated public static float nextFloat(final float startInclusive, final float endExclusive) { return secure().randomFloat(startInclusive, endExclusive); } @@ -162,7 +174,9 @@ public class RandomUtils { * @return the random integer * @see #nextInt(int, int) * @since 3.5 + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated public static int nextInt() { return secure().randomInt(); } @@ -175,7 +189,9 @@ public class RandomUtils { * @throws IllegalArgumentException if {@code startInclusive > endExclusive} or if {@code startInclusive} is * negative * @return the random integer + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated public static int nextInt(final int startInclusive, final int endExclusive) { return secure().randomInt(startInclusive, endExclusive); } @@ -186,7 +202,9 @@ public class RandomUtils { * @return the random long * @see #nextLong(long, long) * @since 3.5 + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated public static long nextLong() { return secure().randomLong(); } @@ -196,7 +214,9 @@ public class RandomUtils { * * @param n Bound on the random number to be returned. Must be positive. * @return a random {@code long} value between 0 (inclusive) and {@code n} (exclusive). + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated private static long nextLong(final long n) { return secure().randomLong(n); } @@ -209,7 +229,9 @@ public class RandomUtils { * @throws IllegalArgumentException if {@code startInclusive > endExclusive} or if {@code startInclusive} is * negative * @return the random long + * @deprecated Use {@link #secure()} or {@link #insecure()}. */ + @Deprecated public static long nextLong(final long startInclusive, final long endExclusive) { return secure().randomLong(startInclusive, endExclusive); }