Commit fb997fc
authored
Make DeclarativeRecipe.accumulator thread-safe with ThreadLocal (#6810)
* Make DeclarativeRecipe.accumulator thread-safe with ThreadLocal
DeclarativeRecipe.accumulator was a plain field that gets set during the
scan phase via getInitialValue(). When the same DeclarativeRecipe instance
is shared across concurrent recipe runs (e.g. via a recipe cache), one
run's scan phase overwrites the accumulator set by another run. This
causes the second run to use stale or null accumulator state during the
edit phase, resulting in precondition scanning recipes producing incorrect
results (typically 0 file changes).
This changes the accumulator field to a ThreadLocal so each run thread
gets its own independent accumulator. The clone() method is also
overridden to create a fresh ThreadLocal for cloned instances.
* Clean up ThreadLocal in onComplete() to prevent memory leaks1 parent 43328e1 commit fb997fc
1 file changed
Lines changed: 16 additions & 4 deletions
Lines changed: 16 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | 164 | | |
166 | | - | |
| 165 | + | |
167 | 166 | | |
168 | 167 | | |
169 | 168 | | |
170 | 169 | | |
171 | 170 | | |
172 | 171 | | |
173 | 172 | | |
174 | | - | |
| 173 | + | |
175 | 174 | | |
176 | 175 | | |
177 | 176 | | |
| |||
509 | 508 | | |
510 | 509 | | |
511 | 510 | | |
512 | | - | |
| 511 | + | |
| 512 | + | |
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| |||
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
605 | 617 | | |
606 | 618 | | |
607 | 619 | | |
| |||
0 commit comments