Commit 9a2690b
committed
Initialize ScanningRecipe accumulator key eagerly
The recipeAccMessage field used lazy initialization that was not
thread-safe. If two concurrent recipe runs accessed the same shared
ScanningRecipe instance before initialization, both threads could
generate different UUIDs, causing one thread's accumulator data to
be stored under a key that gets overwritten.
Change to eager initialization at field declaration, which is
inherently thread-safe since the JVM guarantees constructor
completion before the object is visible to other threads.1 parent 32095ac commit 9a2690b
1 file changed
Lines changed: 2 additions & 6 deletions
Lines changed: 2 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
40 | 39 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 40 | + | |
45 | 41 | | |
46 | 42 | | |
47 | 43 | | |
| |||
0 commit comments