Fix dangling pointer from failure in SchemaStore::RegenerateDerivedFiles.
Essentially, SchemaStore::SetSchema would work in three steps:
1. Write the new schema
2. Throw out derived data structures
3. Regenerate the derived date structures
A failure in the middle of step 3 could cause SectionManager to maintain a a reference to a now-deleted instance of KeyMapper which would then crash on the next access. This resolves that issue via shadowing to ensure that changes are only applied if everything is successfully generated.
You can find the full description of the bug at b/231416401#comment10.
This is a cherrypick of cl/449537037 and cl/450024848. The changes in cl/449849170 (and replaced with direct calls to delete the temp directories) were excluded to keep the size of cherrypick smaller.
Test: Builds
Change-Id: Ic018ade45b5aab4b797a0a654eaea6ac424469ab
10 files changed