Commit 188e93d
committed
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.1 parent 15ebbf2 commit 188e93d
1 file changed
Lines changed: 11 additions & 4 deletions
Lines changed: 11 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 | + | |
605 | 612 | | |
606 | 613 | | |
607 | 614 | | |
| |||
0 commit comments