Commit 4fee380
committed
HBASE-26582 Prune use of Random and SecureRandom objects
Avoid the pattern where a Random object is allocated, used once or twice, and
then left for GC. This pattern triggers warnings from some static analysis tools
because this pattern leads to poor effective randomness. In a few cases we were
legitimately suffering from this issue; in others a change is still good to
reduce noise in analysis results.
Use ThreadLocalRandom where there is no requirement to set the seed to gain
good reuse.
Where useful relax use of SecureRandom to simply Random or ThreadLocalRandom,
which are unlikely to block if the system entropy pool is low, if we don't need
crypographically strong randomness for the use case. The exception to this is
normalization of use of Bytes#random to fill byte arrays with randomness.
Because Bytes#random may be used to generate key material it must be backed by
SecureRandom.1 parent a49c758 commit 4fee380
File tree
145 files changed
+483
-579
lines changed- hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs
- hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer
- hbase-client/src
- main/java/org/apache/hadoop/hbase
- client
- filter
- slowlog
- test/java/org/apache/hadoop/hbase
- security
- util
- hbase-common/src
- main/java/org/apache/hadoop/hbase
- io/encoding
- util
- test/java/org/apache/hadoop/hbase
- io/util
- util
- hbase-hadoop-compat/src/test/java/org/apache/hadoop/hbase
- hbase-http/src/test/java/org/apache/hadoop/hbase/http
- hbase-it/src/test/java/org/apache/hadoop/hbase
- chaos/actions
- ipc
- mapreduce
- test
- trace
- hbase-mapreduce/src/test/java/org/apache/hadoop/hbase
- mapreduce
- util
- hbase-metrics/src/test/java/org/apache/hadoop/hbase/metrics/impl
- hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store
- wal
- hbase-replication/src/test/java/org/apache/hadoop/hbase/replication
- hbase-rest/src/test/java/org/apache/hadoop/hbase/rest
- hbase-server/src
- main/java/org/apache/hadoop/hbase
- io/hfile
- master
- regionserver
- compactions
- wal
- replication/regionserver
- tool
- util
- test/java/org/apache/hadoop/hbase
- client
- locking
- coprocessor
- io
- compress
- encoding
- hfile
- bucket
- master
- assignment
- balancer
- cleaner
- procedure
- mob
- quotas
- regionserver
- compactions
- throttle
- replication
- regionserver
- rsgroup
- util
- wal
- hbase-testing-util/src/main/java/org/apache/hadoop/hbase
- hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
145 files changed
+483
-579
lines changedLines changed: 5 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | 75 | | |
77 | | - | |
78 | 76 | | |
79 | | - | |
80 | 77 | | |
81 | | - | |
82 | 78 | | |
| 79 | + | |
83 | 80 | | |
84 | 81 | | |
85 | 82 | | |
| |||
108 | 105 | | |
109 | 106 | | |
110 | 107 | | |
111 | | - | |
112 | 108 | | |
| 109 | + | |
113 | 110 | | |
114 | | - | |
| 111 | + | |
115 | 112 | | |
116 | 113 | | |
117 | 114 | | |
| |||
123 | 120 | | |
124 | 121 | | |
125 | 122 | | |
126 | | - | |
| 123 | + | |
127 | 124 | | |
128 | 125 | | |
129 | 126 | | |
130 | | - | |
| 127 | + | |
131 | 128 | | |
132 | 129 | | |
133 | 130 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | | - | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
Lines changed: 4 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | 22 | | |
| 23 | + | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | | - | |
| 39 | + | |
| 40 | + | |
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
| |||
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
53 | | - | |
| 52 | + | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| |||
98 | 97 | | |
99 | 98 | | |
100 | 99 | | |
101 | | - | |
| 100 | + | |
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
53 | | - | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
| |||
139 | 138 | | |
140 | 139 | | |
141 | 140 | | |
142 | | - | |
| 141 | + | |
143 | 142 | | |
144 | 143 | | |
145 | 144 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | | - | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | | - | |
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
113 | | - | |
| 112 | + | |
114 | 113 | | |
115 | 114 | | |
116 | 115 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2358 | 2358 | | |
2359 | 2359 | | |
2360 | 2360 | | |
| 2361 | + | |
| 2362 | + | |
2361 | 2363 | | |
2362 | 2364 | | |
2363 | 2365 | | |
| |||
0 commit comments