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
tree: 6270ab3bbe9a035ec333d04df2a9729efbce8684
  1. icing/
  2. java/
  3. nativeLib/
  4. proto/
  5. .gitignore
  6. Android.bp
  7. AndroidManifest.xml
  8. build.gradle
  9. CMakeLists.txt
  10. CONTRIBUTING.md
  11. LICENSE
  12. METADATA
  13. MODULE_LICENSE_APACHE2
  14. OWNERS
  15. README.md
  16. synced_AOSP_CL_number.txt
  17. TEST_MAPPING
README.md

Icing Search Library

Icing is a fast, embedded, mobile-friendly full-text-search library written in C++.

This is not an officially supported Google product.