Replace `new Random()` with `ThreadLocalRandom`
- 主要语言
- Java
- 星标
- 6.4k
- 派生
- 1.2k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 115
描述
`ThreadLocalRandom` provides better performance than `Random`. I think we should replace the `Random` class except test files or example files.
I search the project files, the `Random` class in the following class or method should be replaced:
- Method: `org.apache.iotdb.influxdb.session.InfluxDBSession#reconnect`
- Class: `org.apache.iotdb.cluster.log.snapshot.PullSnapshotTask`
- Class: `org.apache.iotdb.cluster.server.heartbeat.HeartbeatThread`
- Abstract Class: `org.apache.iotdb.cluster.server.member.RaftMember`
- Class: `org.apache.iotdb.db.engine.modification.ModificationFile`
- Class: `org.apache.iotdb.db.engine.storagegroup.TsFileResource`
- Method: `org.apache.iotdb.db.service.thrift.impl.InternalServiceImpl#getHeartBeat`
- Method: `org.apache.iotdb.session.SessionConnection#reconnect`
- Class: `org.apache.iotdb.library.dprofile.UDTFSample`
- Class: `org.apache.iotdb.commons.udf.builtin.UDTFEqualSizeBucketRandomSample`
Related issue: #5880
贡献指南
调研方向
定位列出的 Java 类和方法,包括 InfluxDBSession#reconnect、PullSnapshotTask、HeartbeatThread、RaftMember、ModificationFile、TsFileResource、InternalServiceImpl#getHeartBeat、SessionConnection#reconnect、UDTFSample 和 UDTFEqualSizeBucketRandomSample。检查 Random 的每一处生产代码使用,排除测试文件和示例文件。完成标准是,列出的符合条件的使用都使用 ThreadLocalRandom,并且相关 issue #5880 保持一致。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- backend, databases
- Issue 类型
- 重构
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100