This is an automated email from the ASF dual-hosted git repository. zhangliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push: new 8f5b7a8d125 Replace ThreadLocalRandom with SecureRandom for better security (#35411) 8f5b7a8d125 is described below commit 8f5b7a8d12551f2cacf22a6c5279707f3fe07996 Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Thu May 15 02:07:41 2025 +0800 Replace ThreadLocalRandom with SecureRandom for better security (#35411) - Use SecureRandom instead of ThreadLocalRandom for generating random numbers - This change improves the security of the random selection process - The performance impact is negligible for this specific use case --- .../tableless/type/unicast/TablelessDataSourceUnicastRouteEngine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/tableless/type/unicast/TablelessDataSourceUnicastRouteEngine.java b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/tableless/type/unicast/TablelessDataSourceUnicastRouteEngine.java index 09cf89cdd9d..4cfb39e3695 100644 --- a/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/tableless/type/unicast/TablelessDataSourceUnicastRouteEngine.java +++ b/infra/route/src/main/java/org/apache/shardingsphere/infra/route/engine/tableless/type/unicast/TablelessDataSourceUnicastRouteEngine.java @@ -24,10 +24,10 @@ import org.apache.shardingsphere.infra.route.context.RouteMapper; import org.apache.shardingsphere.infra.route.context.RouteUnit; import org.apache.shardingsphere.infra.route.engine.tableless.TablelessRouteEngine; +import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.concurrent.ThreadLocalRandom; /** * Tableless datasource unicast route engine. @@ -48,6 +48,6 @@ public final class TablelessDataSourceUnicastRouteEngine implements TablelessRou } private String getRandomDataSourceName(final Collection<String> dataSourceNames) { - return new ArrayList<>(dataSourceNames).get(ThreadLocalRandom.current().nextInt(dataSourceNames.size())); + return new ArrayList<>(dataSourceNames).get(new SecureRandom().nextInt(dataSourceNames.size())); } }