Search code examples
kotlinandroid-roomdatabase-migration

Migration script fails with IllegalStateException due to SHADOW_TABLE_NAME_SUFFIXES


I've updated the Room version from 2.4.3 to 2.5.0-alpha03 and after the last migration, the JSON generated will once in a while fail with

Caused by: java.lang.IllegalStateException: Cannot parse existing schema file: C:\mypath\com.example.MyDatabase\74.json. If you've modified the file, you might've broken the JSON format, try deleting the file and re-running the compiler. 
If you've not modified the file, please file a bug at 
https://issuetracker.google.com/issues/new?component=413107&template=1096568 
with a sample app to reproduce the issue.   
    at androidx.room.vo.Database.exportSchema(Database.kt:111)  
    at androidx.room.DatabaseProcessingStep.process(DatabaseProcessingStep.kt:123)  
    at androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:123)     
    at androidx.room.compiler.processing.javac.JavacBasicAnnotationProcessor.process(JavacBasicAnnotationProcessor.kt:71)   
    at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt:90)    
    at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:197)    
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:985)    ... 44 more

After checking out the differences between the last schema file 73.json and the new one, 74.json, apart from the changes I've wanted to make, there's this block:

    "SHADOW_TABLE_NAME_SUFFIXES": [
      "_content",
      "_segdir",
      "_segments",
      "_stat",
      "_docsize"
    ],
    "shadowTableNames$delegate": {
      "initializer": {},
      "_value": {}
    },

inside the only ftsVersion block I have. Whatever I write in the migration script doesn't matter, I always get the same issue. What I've found is that SHADOW_TABLE_NAME_SUFFIXES is a static variable from androidx.room.migration.bundle.FtsEntityBundle & if I delete this block from 74.json, I don't get the issue anymore.

Can anyone help me with more info on this and why it could pop up in the schema file?


Solution

  • I've posted a bug report as per the stack trace's advice and it seems to be an issue from Room 2.5.0-alpha02 and 2.5.0-alpha03, which they will fix https://issuetracker.google.com/issues/246751839