Commit c2260f0
[LANG-1772] Restrict size of cache to prevent overflow errors (#1379)
* LANG-1772 restrict size of cache to prevent overflow errors
* LANG-1772 Adding a largeheap maven profile. Skipping the testHugeStrings method in all other profiles.
* LANG-1772 Adding javadoc as per request. Also moving max cache size inside the CachedRandomBits constructor - also checking if the padding produces overflow. No longer using an arbitrary value but being more precise.
* LANG-1772 Suggestions from PR implemented
* LANG-1772 Using a long for the intermediate calculation and restricting the result to MAX_INT/5, also restricting max cache length to MAX_INT/3, there are now no opportunities for overflow. The test checks at the boundary condition
* Close HTML tag
* LANG-1772 Introduced many constants, and attempted to add comprehensive documentation around the nextBits method and the size allocation for the cache
* Update src/main/java/org/apache/commons/lang3/RandomStringUtils.java
You're right, should be outside the min
Co-authored-by: Piotr P. Karwasz <[email protected]>
---------
Co-authored-by: James Winters <[email protected]>
Co-authored-by: Gary Gregory <[email protected]>
Co-authored-by: Piotr P. Karwasz <[email protected]>1 parent 3f7868e commit c2260f0
File tree
4 files changed
+87
-15
lines changed- src
- main/java/org/apache/commons/lang3
- test/java/org/apache/commons/lang3
4 files changed
+87
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
114 | 117 | | |
115 | 118 | | |
116 | 119 | | |
| |||
460 | 463 | | |
461 | 464 | | |
462 | 465 | | |
463 | | - | |
| 466 | + | |
464 | 467 | | |
465 | 468 | | |
466 | 469 | | |
| |||
522 | 525 | | |
523 | 526 | | |
524 | 527 | | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
525 | 535 | | |
526 | 536 | | |
527 | 537 | | |
| |||
Lines changed: 48 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
55 | 69 | | |
56 | 70 | | |
57 | 71 | | |
| |||
62 | 76 | | |
63 | 77 | | |
64 | 78 | | |
65 | | - | |
| 79 | + | |
66 | 80 | | |
67 | 81 | | |
68 | 82 | | |
| |||
71 | 85 | | |
72 | 86 | | |
73 | 87 | | |
74 | | - | |
75 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
76 | 100 | | |
77 | 101 | | |
78 | | - | |
79 | | - | |
| 102 | + | |
| 103 | + | |
80 | 104 | | |
81 | 105 | | |
82 | 106 | | |
83 | 107 | | |
| 108 | + | |
| 109 | + | |
84 | 110 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
88 | 114 | | |
89 | 115 | | |
90 | 116 | | |
91 | | - | |
92 | | - | |
93 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
94 | 125 | | |
95 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
96 | 132 | | |
97 | 133 | | |
98 | 134 | | |
| |||
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
| |||
329 | 333 | | |
330 | 334 | | |
331 | 335 | | |
332 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
333 | 346 | | |
334 | 347 | | |
335 | 348 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
| |||
802 | 807 | | |
803 | 808 | | |
804 | 809 | | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
805 | 818 | | |
0 commit comments