Use SecureRandom in RandomValuePropertySource

Closes gh-50172
This commit is contained in:
Andy Wilkinson
2026-04-23 08:51:14 +01:00
parent e22083a568
commit f3b8eb0f2c
2 changed files with 3 additions and 2 deletions
@@ -16,6 +16,7 @@
package org.springframework.boot.env;
import java.security.SecureRandom;
import java.util.HexFormat;
import java.util.OptionalInt;
import java.util.OptionalLong;
@@ -77,7 +78,7 @@ public class RandomValuePropertySource extends PropertySource<Random> {
}
public RandomValuePropertySource(String name) {
super(name, new Random());
super(name, new SecureRandom());
}
@Override
@@ -50,7 +50,7 @@ class RandomValuePropertySourceTests {
@Test
void getPropertyWhenStringReturnsValue() {
assertThat(this.source.getProperty("random.string")).isNotNull();
assertThat(this.source.getProperty("random.string")).isNotNull().asString().containsPattern("^[0-9a-f]{32}$");
}
@Test