Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • briar briar
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 786
    • Issues 786
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • briar
  • briarbriar
  • Issues
  • #1921

Closed
Open
Created Feb 03, 2021 by akwizgran@akwizgranOwner

PluginViewModel should wait for DB to open before loading settings

While testing something unrelated on the 1.2.12 release I noticed this exception in the log:

02-03 16:15:52.017 2925-2952/org.briarproject.briar.android.debug W/PluginViewModel: org.briarproject.bramble.api.db.DbClosedException
    org.briarproject.bramble.api.db.DbClosedException
        at org.briarproject.bramble.db.H2Database.createConnection(H2Database.java:97)
        at org.briarproject.bramble.db.JdbcDatabase.startTransaction(JdbcDatabase.java:554)
        at org.briarproject.bramble.db.JdbcDatabase.startTransaction(JdbcDatabase.java:97)
        at org.briarproject.bramble.db.DatabaseComponentImpl.startTransaction(DatabaseComponentImpl.java:161)
        at org.briarproject.bramble.db.DatabaseComponentImpl.transactionWithResult(DatabaseComponentImpl.java:208)
        at org.briarproject.bramble.settings.SettingsManagerImpl.getSettings(SettingsManagerImpl.java:26)
        at org.briarproject.briar.android.navdrawer.PluginViewModel.isPluginEnabled(PluginViewModel.java:204)
        at org.briarproject.briar.android.navdrawer.PluginViewModel.lambda$loadSettings$0$PluginViewModel(PluginViewModel.java:187)
        at org.briarproject.briar.android.navdrawer.-$$Lambda$PluginViewModel$HPPDOnjY7Hk6kE7RpR2no4vHis8.run(lambda)
        at org.briarproject.bramble.TimeLoggingExecutor.lambda$execute$0$TimeLoggingExecutor(TimeLoggingExecutor.java:36)
        at org.briarproject.bramble.-$$Lambda$TimeLoggingExecutor$Bqrtbsq_8LcRPoTWBOef6xh7gJg.run(lambda)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)

This happens at startup when NavDrawerActivity is created before signing in, as PluginViewModel tries to load the plugin settings.

This is currently harmless because a new NavDrawerActivity instance is created after signing in, with a new view model instance that successfully loads the settings. But that's just a lucky accident. To avoid depending on that, perhaps it would be better to refactor PluginViewModel to use DbViewModel#runOnDbThread()?

Edited Feb 03, 2021 by akwizgran
Assignee
Assign to
Time tracking